dotansimha / dotansimha/graphql-code-generator

Rework isFragmentReady API

Open
#9,999 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Is your feature request related to a problem? Please describe.

Today, if multiple fragments select the same fields, but have a different selection set within the individual fields that resolve to an object type or similar, will give false results.

**Example:**

```graphql
fragment A on Object {
a
b {
c
}
}

fragment B on Object {
a
b {
d
}
}

query Foo {
a
...A @defer
...B @defer
}
```

Since we only check whether the fields on the query type (`Query.a`, `Query.b`) exist within the `isFragmentReady` helper, even if only the data for the `A` fragment arrived on the client, the `isFragmentReady` helper will return `true` for the check on the `B` fragment.

Instead,we should focus on a new API that first drops the need for passing the operation document node to `isFragmentReady`, but also does structural data checks on whether all the data selected within the fragment is satisfied within the object provided.

That will require storing a minimal representation of all the fragment fields (and also subfields) within the `TypedDocumentNode` / `TypedDocumentString`.

### Describe the solution you'd like

-

### Describe alternatives you've considered

_No response_

### Is your feature request related to a problem? Please describe.

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.