[AC@3] MissingFieldError should be muted by default because fields can be optional
See original GitHub issueAC (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:
- Created 3 years ago
- Reactions:6
- Comments:8 (1 by maintainers)
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 catchMissingFieldError
explicitly to overcome this problem.+1 on this.