question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't find field on ROOT_QUERY object error on 3.4.x and up

See original GitHub issue

Hello,

After upgrading to 3.4.x, I have had problems with certain queries being reissued with different variables resulting in an Apollo error that crashes my app.

Intended outcome:

useQuery can be re-executed multiple times with different variables and not crash.

Actual outcome:

This crash happens:

error

Following the traceback, I placed a debugger in ObservableQuery at getCurrentResult:

Screen Shot 2021-08-05 at 3 11 44 PM

Note that the network request worked and the backend resolved the query successfully:

Screen Shot 2021-08-05 at 3 15 02 PM

How to reproduce the issue:

I am having a lot of difficulty reproducing the error in the sandbox, but here’s a bunch of things that I tried / additional information:

  • The affected queries have deeply-nested arguments, where subsequent queries change things that are deeply nested, e.g.
{
 "limit": 25,
 "offset": 0,
 "filters": [ /* deeply nested objects w/arrays. This is what changes between queries */ ]
}
  • This error still happens when I do fetchPolicy: 'network-only' and nextFetchPolicy: 'network-only'
  • Still happens when I call refetch with new variables or the same query with new variables
  • I also tried doing skip: true and only using refetch and it still happened
  • Also tried this setting on the apollo client instance after reading the CHANGELOG and it did not resolve the issue:
new ApolloClient({
  defaultOptions: {
    watchQuery: {
      refetchWritePolicy: "merge",
    },
  },
})

Versions

I reproduced this error on the following:

  • 3.4.0
  • 3.4.1
  • 3.4.5
  • 3.5.0-beta.4

However downgrading to 3.3.21 fixed the issues.

Additional Notes

I’m wondering if this could possibly be related to https://github.com/apollographql/apollo-client/pull/8422 because it touched the file where I’m getting the error.

Please let me know if there’s anything to try or if any additional info would be helpful.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
brainkimcommented, Aug 6, 2021

Related: https://github.com/apollographql/apollo-client/issues/8442

I’m also seeing transitory Missing Cache Field errors on the error property in unit tests while refactoring code. A potential option might be to make these console warnings only.

2reactions
huetercommented, Aug 5, 2021

Ah interesting, thank you for the insight! I guess it’s a tough call from the API design perspective, but as an end user I was expecting result.error to be present only if it were fatal – although I know some folks might expect partial failures with GraphQL, so I’m not sure if I should change my assumption to always throw if the error is present. Would this be related to the error policy settings, i.e. is there an error policy that lets me ignore non-backend / network errors?

I also just tested the code and setting the query’s fetchPolicy to no-cache fixed the issue. Previously I only tested it with network-only, but I see now according to the docs that network-only still writes to the cache after the network request is complete.

I’ll have to read up on the caching serialization to see if that could provide an alternative as well.

Thanks for the follow-up! This has been helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't find field <field> on object (ROOT_QUERY) undefined.
I'm using ReactNative, and am able to load a user object from my graphql server using graphql(gql`{ user(id: 1) { first_name } ...
Read more >
Apollo-client - Error: Can't find field allLinks({}) on object ...
So, I'm experiencing the above mentioned error when attempting to run a query with a graphcool endpoint. The issue only occurs when ...
Read more >
Federation error codes - Apollo GraphQL Docs
Indicates an error in a subgraph service query during query execution in a federated service. 0.x. EMPTY_MERGED_ENUM_TYPE, An enum type has no value...
Read more >
Frequently Asked Questions - TypeGraphQL
This error occurs when the resolver (query, mutation, field) type is an interface/union and a plain object is returned from it. In this...
Read more >
PS3.4 - DICOM Standard - NEMA
A concrete occurrence of an Information Object that is managed by a DICOM Application Entity and may be operated upon in a communication...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found