Why I got error: Cannot query field xx on type "Query"?
The fault with my query was that I didn't download the new schema.
You can download the schema by using: apollo schema:download --endpoint=http://localhost:8080/graphql schema.json
replace http://localhost:8080/graphql with your server endpoint
You can see more at https://www.apollographql.com/docs/ios/downloading-schema/
In my case, I had defined a query which didn't require any parameters and it would return an array of objects:
myBasicQuery: [BasicAnswer]type BasicAnswer { name String phone String}
I was getting the error: Cannot query field \"BasicAnswer\" on type \"BasicAnswer\"
when I declared it like this:
query myBasicQuery { BasicAnswer { name phone }}
Leaving only the fields of BasicAnswer fixed the issue:
query myBasicQuery { name phone}
For anyone else who might be searching for this problem, make sure you're importing ApolloClient
from apollo-client
package and not other packages.