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.

[AC@3] MissingFieldError should be muted by default because fields can be optional

See original GitHub issue

AC (from 3.0.0-beta.43) is raising a MissingFieldError if a @client query includes fields that are missing in the underlying cached object.

I can understand this, but assuming that there is no schema validation client-side, and that the field could be optional, a simple query like this:

query {
  myObject @client {
    optionalField
  }
}

Even with { returnPartialData: true }

Will raise a MissingFieldError if optionalField is not initialised. For a trivial example like the Todo app (using ReactiveVar for managing the local state), all fields can be initialised. For a real life app, it is not something always possible, and would greatly complexifies migrations.

IMHO this error should be muted by default. Checking client query fields against an eventual schema should be done offline (ie. with a graphql code generator) and should not raise warning (or errors) at runtime for fields that are potentially optional.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
lxcidcommented, Sep 24, 2020

usually points to an error in your code

I disagree with that as well. So the idea of GraphQL is to fetch what you need. So without ability to mute MissingFieldError, that force us to prefetch information because we might need it in the future doesn’t sounds like its the right thing to do.

I don’t mind this being a default behaviour, but giving developer ability to turn this off would not short change developer who want to take advantage GraphQL unique ability to progressively fill up their cache with only information they need, is fundamentally what make GraphQL popular.

I hope this can be muted. For now, we have to wrap it inside a try/catch and catch MissingFieldError explicitly to overcome this problem.

3reactions
yippiracommented, Sep 24, 2020

+1 on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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