menu

Apollo

A community of developers, designers and others who love Apollo and GraphQL. 🚀

Channels
# All channels
view-forward
# General
view-forward
# Apollo Angular
view-forward
# Announcements
view-forward
# Apollo Android
view-forward
# Apollo Client
view-forward
# Apollo iOS
view-forward
# Apollo Link
view-forward
# Apollo Link Rest
view-forward
# Local State
view-forward
# Apollo Studio
view-forward
# Apollo Server
view-forward
# Apollo Tooling
view-forward
# Contributing
view-forward
# Docs
view-forward
# Events
view-forward
# GraphQL Tools
view-forward
# Jobs
view-forward
# Random
view-forward
# React Apollo
view-forward
# Showcase
view-forward
# Subscriptions
view-forward
# Testing
view-forward
# Vue Apollo
view-forward
Team

useQuery returning undefined

July 13, 2020 at 1:16pm

useQuery returning undefined

July 13, 2020 at 1:16pm
Hey people, whenever I'm using useQuery on my application, the first query that I left below results on data as undefined (and no error either on Network level, nor on the useQuery return). The second query works perfectly, the only difference is the hardcoded data from the exports, which is working fine from what I saw on the network tab. Only difference in the HTTP requests that I saw was that the first query sends firstArray and secondArray as variables on the query, but the result is still right. What am I missing?
Doesn't work:
export const MY_QUERY: DocumentNode = gql`
query someQuery(
$id: ID!
$firstArray: [FirstArrayType]
$secondArray: [SecondArrayType]
) {
firstArray @client @export(as: "firstArray") {
field
}
secondArray @client @export(as: "secondArray") {
field
}
someId @client @export(as: "id")
myData(id: $id) {
id
otherData(first: $firstArray, second: $secondArray) {
...
}
}
}
`;
Works:
export const MY_QUERY: DocumentNode = gql`
query someQuery($id: ID!) {
someId @client @export(as: "id")
myData(id: $id) {
id
otherData(first: [], second: []) {
...
}
}
}
`;
No messages yet