поле после GraphQL запроса undefined
Столкнулся с такой проблемой. После GraphQL запроса через useQuery в Apollo данные приходят, но я не могу получить доступ к этим данным. Пишет undefined. Может я что-то не так делаю?
const LocationSearchInput = ({ onSet, defaultValue, ...otherProps }) => {
const [err, setErr] = useState(null)
const [val, setVal] = useState("")
const [sel, setSel] = useState(null)
const [locations, setLocations] = useState(null)
const [searchLocation] = useMutation(SEARCH_LOCATIONS)
useQuery(GET_LOCATION, {
variables: { id: +defaultValue },
onCompleted: data => {
const location = data.locations[0]
console.log(location)
console.log(location.info.title)
},
onError: err => setErr(err)
})
После первого консоль лога данные благополучно выводятся.
А как только пытаюсь получить доступ к конкретному полю:
Никак не пойму почему так?(
Запрос имеет следующий вид:
const GET_LOCATION = gql`
query GetLocation($id: ID) {
locations(id: $id) {
_id
info {
title
}
type
}
}
`

