-
-
Notifications
You must be signed in to change notification settings - Fork 821
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: Fixed Transforming wrapped input fields #4676
fix: Fixed Transforming wrapped input fields #4676
Conversation
🦋 Changeset detectedLatest commit: 719fc36 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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 |
Someone is attempting to deploy a commit to the The Guild Team on Vercel. A member of the Team first needs to authorize it. |
Thanks for the PR! |
@@ -165,7 +167,10 @@ export default class TransformInputObjectFields<TContext = Record<string, any>> | |||
// The casting is kind of legit here as we are in a visitor | |||
const parentType = typeInfo.getInputType() as Maybe<GraphQLInputObjectType>; |
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.
We shouldn't do casting here if we have the following check right?
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.
getInputType
returns a GraphQLInputType
instead of GraphQLInputObjectType
, and does not have the property name
. So on the ternary operator if the check fails it falls back to the original logic of just parentType.name
. So I am not sure how we could do this without casting it here
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.
Removed with the getNamedType
change
Will do 👍 |
Unit test added, it is a copy of the first one with the exception that the argument is non-null. I decided to do it this way because while the tests are exactly the same, they test different parts of the code due to the argument differences. If you remove the fix of this PR the unit test will fail with the following:
|
@@ -165,7 +167,10 @@ export default class TransformInputObjectFields<TContext = Record<string, any>> | |||
// The casting is kind of legit here as we are in a visitor | |||
const parentType = typeInfo.getInputType() as Maybe<GraphQLInputObjectType>; | |||
if (parentType != null) { | |||
const parentTypeName = parentType.name; | |||
const parentTypeName = | |||
isWrappingType(parentType) && isInputObjectType(parentType.ofType) |
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.
Related https://github.com/ardatan/graphql-tools/pull/4676/files#r956002686
Can we do getNamedType
here because ofType
can be also another wrapped type, right?
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.
Well spotted! you can indeed have an "infinite" amount of wraps, will change it
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.
Done!
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.
Awesome! Then could you create a changeset using yarn changeset
then we can merge and cut a release?
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.
Done! Please check if the changeset makes sense 👍
Thanks @NullScope :) |
No problem! Thanks for the speedy review! |
🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.
Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Related #4675
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?
Test Environment:
@graphql-tools/wrap
: 9.0.4Checklist:
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...