-
-
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ import { | |
OperationDefinitionNode, | ||
isInputType, | ||
NamedTypeNode, | ||
isWrappingType, | ||
isInputObjectType, | ||
} from 'graphql'; | ||
|
||
import { Maybe, ExecutionRequest, MapperKind, mapSchema, transformInputValue } from '@graphql-tools/utils'; | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Related https://github.com/ardatan/graphql-tools/pull/4676/files#r956002686 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Awesome! Then could you create a changeset using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! Please check if the changeset makes sense 👍 |
||
? parentType.ofType.name | ||
: parentType.name; | ||
const newInputFields: Array<ObjectFieldNode> = []; | ||
|
||
for (const inputField of node.fields) { | ||
|
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 aGraphQLInputType
instead ofGraphQLInputObjectType
, and does not have the propertyname
. So on the ternary operator if the check fails it falls back to the original logic of justparentType.name
. So I am not sure how we could do this without casting it hereThere 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