Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement nullability operators in Graphcache
The ["Nullability RFC" for GraphQL](graphql/graphql-wg#694) allows fields to individually be marked as optional or required in a query by the client-side. ([See Strawman Proposal](graphql/graphql-spec#867)) If a field is marked as optional then it's allowed to be missing and `null`, which can control where missing values cascade to: ```graphql query { me { name? } } ``` If a field is marked as required it may never be allowed to become `null` and must cascade if it otherwise would have been set to `null`: ```graphql query { me { name! } } ``` In Graphcache, we imagine that the nullable field — which would be marked with `required: 'optional'` — can allow Graphcache to make more data nullable and hence partial, which enhances schema awareness, even if it's not actively used. The required fields — which would be marked with `required: 'required'` — would force Graphcache to include this data, regardless of what schema awareness may say, which also enhances partial data in the presence of schema awareness, since it increases what the cache may deliver. In other words, it guarantees a "forced outcome" in both cases, without having to look up whether a field is nullable in the schema. In the future, we may even derive the `RequiredStatus` of a `FieldNode` in an external place and never call `isFieldNullable` with a schema in the query traversal.
- Loading branch information