-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix scalar input/output object bug when given external file or module pattern #9418
Conversation
|
🚀 Snapshot Release (
|
Package | Version | Info |
---|---|---|
@graphql-codegen/cli |
3.3.2-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/introspection |
3.0.2-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/visitor-plugin-common |
4.0.0-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-document-nodes |
3.0.5-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/gql-tag-operations |
3.0.2-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-operations |
4.0.0-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-resolvers |
4.0.0-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typed-document-node |
4.1.0-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript |
4.0.0-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/client-preset |
3.1.0-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/graphql-modules-preset |
3.1.4-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/testing |
2.0.3-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/plugin-helpers |
4.2.1-alpha-20230522233947-904521c12 |
npm ↗︎ unpkg ↗︎ |
@@ -1997,6 +2009,9 @@ describe('TypeScript', () => { | |||
MyScalar: { input: MyScalar['input']; output: MyScalar['output']; } | |||
MyOtherScalar: { input: MyOtherScalar['input']; output: MyOtherScalar['output']; } | |||
MyAliasedScalar: { input: AliasedScalar['input']; output: AliasedScalar['output']; } | |||
OrgScalar: { input: OrgScalar['input']; output: OrgScalar['output']; } | |||
OrgOtherScalar: { input: OrgOtherScalar['input']; output: OrgOtherScalar['output']; } | |||
OrgAliasedScalar: { input: OrgAliasedScalar['input']; output: OrgAliasedScalar['output']; } |
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.
I think it would have much better backward compatibility if we don't require mapped scalar from external sources to be an input/output object
Will push a commit to fix 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.
Fixed in 2665abf
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.
You've already done it, but agreed, this last commit is quite nice. Means the only code change we had to do in our (internal) project was stop using Scalars[''] or add the ['input'] / ['output'] type.
💻 Website PreviewThe latest changes are available as preview in: https://13634307.graphql-code-generator.pages.dev |
Description
1. Fix a missed case when handling input/output scalar object
This fixes the issue originally implemented in #9375
Previously, we print the input/output value without parsing it through mapper. This means with the following config:
It will print the following invalid TypeScript syntax 😓 :
Now, input/output scalar object should now handle file and module import mapper consistently i.e. import at the top and reference the imports in the
Scalars
object:2. Ensure backward compatibility when using mapped Scalars
Previous implementation expects external mapped scalar cases have input/output object. Below is the config for these cases
Previously the following would be generated
This is big breaking change for downstream users as all mapped scalar currently is a type instead of an input/output object. This PR updates it so mapped scalars will be used for both input and output:
Type of change
Please delete options that are not relevant.
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
Checklist: