-
Notifications
You must be signed in to change notification settings - Fork 773
useQuery returning undefined #4042
Description
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?
Intended outcome:
The following query should return the same data as the one left in actual outcome:
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) {
...
}
}
}
`;
Actual outcome:
The following query returns the correct data (even if both produce the same HTTP result), but the one above doesn't
export const MY_QUERY: DocumentNode = gql`
query someQuery($id: ID!) {
someId @client @export(as: "id")
myData(id: $id) {
id
otherData(first: [], second: []) {
...
}
}
}
`;
Version
$ npx envinfo@latest --preset apollo --clipboard
npx: installed 1 in 1.906s
System:
OS: macOS 10.15.5
Binaries:
Node: 13.3.0 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.2 - /usr/local/bin/npm
Browsers:
Chrome: 83.0.4103.116
Firefox: 41.0
Safari: 13.1.1
npmPackages:
@apollo/react-hooks: ^3.1.3 => 3.1.3
@apollo/react-testing: ^3.1.3 => 3.1.3
apollo-cache-inmemory: ^1.6.5 => 1.6.5
apollo-client: ^2.6.8 => 2.6.8
apollo-link: ^1.2.13 => 1.2.13
apollo-link-context: 1.0.19 => 1.0.19
apollo-link-error: ^1.1.12 => 1.1.12
apollo-link-http: ^1.5.16 => 1.5.16
apollo-link-persisted-queries: 0.2.2 => 0.2.2
apollo-link-state: ^0.4.2 => 0.4.2
react-apollo: ~3.1.3 => 3.1.3