fix: align filter input type name casing for index and relational query fields - #3525
Open
sharonyajain wants to merge 1 commit into
Open
fix: align filter input type name casing for index and relational query fields#3525sharonyajain wants to merge 1 commit into
sharonyajain wants to merge 1 commit into
Conversation
…ry fields The GSI (@index queryField) and @hasmany connection query fields named their `Model<name>FilterInput` argument type with the model name verbatim (via ModelResourceIDs.ModelFilterInputTypeName), while the model transformer and the generated client use the PascalCased getFilterInputName. For models whose names do not start with an uppercase letter these diverge, so AppSync rejects the client query with a VariableTypeMismatch (e.g. ModelUserPrivateSyncItemFilterInput vs ModeluserPrivateSyncItemFilterInput). Align both transformers to getFilterInputName so the generated schema matches the client. PascalCase model names are unaffected (identical output; no snapshot churn). Fixes aws-amplify/amplify-backend#3267
Simone319
approved these changes
Aug 26, 2026
Contributor
|
Approved if the e2e tests succeeds. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
Amplify Data models whose GraphQL type name does not begin with an uppercase letter (e.g. a model declared as
userPrivateSyncItem) produce a schema whose secondary-index (@indexqueryField) and@hasManyconnection query fields declare afilterargument type that the generated client never sends. At runtime AppSync rejects the query with:Root cause: two helpers name the
Model<name>FilterInputtype with different casing rules:listquery) usesgetFilterInputName→toPascalCase(['Model', name, 'FilterInput']), which capitalizes the model name →ModelUserPrivateSyncItemFilterInput.@hasManyconnection field) usedModelResourceIDs.ModelFilterInputTypeName(name), which is a raw`Model${name}FilterInput`with no capitalization →ModeluserPrivateSyncItemFilterInput.The generated client (
@aws-amplify/data-schema) PascalCases the model name, matching the model transformer. So for a lowercase-first model name the baselistfilter type matches the client, but the GSI /@hasManyfilter type does not — hence the mismatch on those fields only.Fix: align the index and relational transformers to the same
getFilterInputNamehelper the model transformer uses, so the filter input type name is generated consistently.packages/amplify-graphql-index-transformer/src/schema.tsmakeModelXFilterInputObjectnow creates the filter input type viagetFilterInputName(object.name.value).ensureQueryFieldaligns the GSI query field'sfilterargument type to the same name.packages/amplify-graphql-relational-transformer/src/schema.tsmakeModelConnectionFieldandmakeModelXFilterInputObjectnow usegetFilterInputName(relatedType.name.value).For model names that already start with an uppercase letter,
getFilterInputNamereturns a string identical to the previousModelResourceIDs.ModelFilterInputTypeNameoutput, so there is no change for the common case (confirmed by unchanged snapshots). The sharedModelResourceIDs.ModelFilterInputTypeNamehelper is intentionally left untouched, since it is used by other code paths; only the two affected transformers are changed.CDK / CloudFormation Parameters Changed
None. This only changes a generated GraphQL type name (and only for model names that do not begin with an uppercase letter).
Issue #, if available
Fixes aws-amplify/amplify-backend#3267
Description of how you validated changes
amplify-graphql-index-transformer.test.ts— asserts the GSI query field and thelistquery field both referenceModelUserPrivateSyncItemFilterInput, and noModeluserPrivateSyncItemFilterInputtype is emitted.amplify-graphql-has-many-transformer.test.ts— asserts the@hasManyconnection field'sfilterarg isModelOtherPartFilterInput(related modelotherPart), and no lowercase variant is emitted.yarn build+yarn teston both affected packages:eslinton the four changed files: no new lint findings introduced by this change. Pre-existing lint issues in these files (jsdoc,no-shadow,max-depth, function length, etc.) are unrelated to this fix and left as-is per the repo's iterative-lint policy.Checklist
yarn testpasses (for the two affected packages)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.