Can't find field <field> on object (ROOT_QUERY) undefined.
See original GitHub issueI’m using ReactNative, and am able to load a user object from my graphql server using
graphql(gql`{
user(id: 1) {
first_name
}
}`)(DisplayComponent)
Therefore, I would expect this user to be in the cache. However, when I write the following code in the constructor of a different component:
apolloClient.readQuery({query: gql`
query Test {
user(id: 1) {
first_name
}
}
`})
I get the following error:
Can't find field user({"id":1}) on object (ROOT_QUERY) undefined.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:32
- Comments:42 (6 by maintainers)
Top Results From Across the Web
react apollo - readQuery from cache results in Can't find field ...
I'm doing some simple queries and mutations fine but when I try to access data from apollo cache I keep getting "Can't find...
Read more >Configuring the Apollo Client cache - Apollo GraphQL Docs
To learn how to interact with cached data, see Reading and writing data to the cache. ... Include a keyFields field in relevant...
Read more >GraphQL specification
When querying an Object, the resulting mapping of fields are conceptually ordered in the same order in which they were encountered during query...
Read more >ObjectType - Graphene-Python
ObjectType¶. A Graphene ObjectType is the building block used to define the relationship between Fields in your Schema and how their data is...
Read more >GraphQL Content API - Contentful
Collection fields. Collections of entries and assets are exposed through collection fields in the root query object and in one-to- ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For what it’s worth, I ran into the same issue and found out that I forgot the variables when calling
readQuery
:Maybe it can help someone 😃
Closing this for lack of activity. If it’s still an issue, please provide a reproduction and we’ll reopen. Thanks! 🙂