-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @defer
directive support
#9196
Conversation
🦋 Changeset detectedLatest commit: ccdac2a The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🚀 Snapshot Release (
|
Package | Version | Info |
---|---|---|
@graphql-codegen/visitor-plugin-common |
3.2.0-alpha-20230501115039-7ad08f56b |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-document-nodes |
3.0.5-alpha-20230501115039-7ad08f56b |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/gql-tag-operations |
3.0.2-alpha-20230501115039-7ad08f56b |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-operations |
3.1.0-alpha-20230501115039-7ad08f56b |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-resolvers |
3.3.0-alpha-20230501115039-7ad08f56b |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typed-document-node |
4.1.0-alpha-20230501115039-7ad08f56b |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript |
3.1.0-alpha-20230501115039-7ad08f56b |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/client-preset |
3.1.0-alpha-20230501115039-7ad08f56b |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/graphql-modules-preset |
3.1.4-alpha-20230501115039-7ad08f56b |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/plugin-helpers |
4.2.1-alpha-20230501115039-7ad08f56b |
npm ↗︎ unpkg ↗︎ |
💻 Website PreviewThe latest changes are available as preview in: https://533e96b2.graphql-code-generator.pages.dev |
6a733d6
to
3a8577e
Compare
diff --git a/website/algolia-lockfile.json b/website/algolia-lockfile.json
index 0f7eb7c78..c7a013b40 100644
--- a/website/algolia-lockfile.json
+++ b/website/algolia-lockfile.json
@@ -2018,6 +2018,11 @@
"title": "Fragment Masking with nested Fragments",
"anchor": "fragment-masking-with-nested-fragments"
},
+ {
+ "children": [],
+ "title": "Fragment Masking with @defer directive",
+ "anchor": "fragment-masking-with-defer-directive"
+ },
{
"children": [],
"title": "Fragment Masking and testing", |
const fragName = fragDef?.name?.value; | ||
|
||
const fields = fragName ? deferredFields[fragName] : []; | ||
return fields.length > 0 && fields.every(field => data && field in data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While testing the release candidate which includes this PR, I realised that if an user has noUncheckedIndexedAccess
turned on in their tsconfig.son
, the fields
variable might be undefined, hence doing fields.length
or fields.every
fails and TS complains about it. Not sure how to fix this. Should I open an issue? Also apologies if this is not the place to comment about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! You can open an issue and I'll improve this function to work with noUncheckedIndexedAccess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a fix: #9385
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a fix: #9385
Thanks!!
An extension PR to #8785. The main difference is that this PR generates a union of initial and deferred types instead of marking deferred types as optional. Reference: #8785 (comment)
Example in Hive: https://github.com/kamilkisiela/graphql-hive/compare/main...beerose:graphql-hive:add-defer?expand=1#diff-0defc8c1055b10af21b6f4dbf38e1ae168ce19de44dedb523676ce9034704782R173
Description
Found some legacy code and added more 🤡
Related #7885
Type of change
Please delete options that are not relevant.
Screenshots/Sandbox (if appropriate/relevant):
Adding links to sandbox or providing screenshots can help us understand more about this PR and take action on it as appropriate
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Environment:
@graphql-codegen/...
:Checklist:
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...