amplify-codegen
amplify-codegen copied to clipboard
Migration to graphql v2 is creating an issue with capitalization of of non model type in schema.graphql . Unknown type "OvertimeDetailInput". Did you mean "overtimeDetailInput" or "overtimeDetail"?
Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have searched for duplicate or closed issues.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
v14.17.4
Amplify CLI Version
8.0.2
What operating system are you using?
Ubuntu 20.04 on WSL
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made
Amplify Categories
api
Amplify Commands
Not applicable
Describe the bug
On migrating to new graphqlTransformer v2 it is causing issues with capitalization on an array of type in schema.graphql
file. e,g
type QuoteInfo @model{
id: ID!
overtimeDetails: [overtimeDetail]
}
type overtimeDetail {
multiplier: float
overtimeHours: float
}
This gives me the issue when mocking or pushing to backend of Unknown type "OvertimeDetailInput". Did you mean "overtimeDetailInput" or "overtimeDetail"?
From what I can see in API.ts file auto generated when using the old graphqltransformer v1, It has created the following types:
export type CreateQuoteInfoInput = {
id?: string | null,
overtimeDetails?: Array< OvertimeDetailInput | null > | null,
}
export type OvertimeDetailInput = {
multiplier?: number | null,
overtimeHours?: number | null,
}
export type UpdateQuoteInfoInput = {
id?: string | null,
overtimeDetails?: Array< OvertimeDetailInput | null > | null,
}
Note the capital O
in OvertimeDetailInput
above compared to the type overtimeDetail
as the type in schema.graphql
. Also seeing OvertimeDetailInput
in the auto generated schema.json
at src/graphql
Expected behavior
Error shouldn't occur when mocking or pushing to amplify backend.
Reproduction steps
- Create the schema above using graphql Transformer v1
- amplify push
- amplify migrate api
- amplify mock
GraphQL schema(s)
# Put schemas below this line
type QuoteInfo @model{
id: ID!
overtimeDetails: [overtimeDetail]
}
type overtimeDetail {
multiplier: float
overtimeHours: float
}
Log output
# Put your logs below this line
Failed to start API Mock endpoint Error: Unknown type "OvertimeDetailInput". Did you mean "overtimeDetailInput" or "overtimeDetail"?
Additional information
No response
Hello @DevTGhosh, Thank you for reporting this . I was able to replicate this behaviour in my Amplify application. marking this as bug.
Note: observed the following in the build schema.
input overtimeDetailInput {
multiplier: Float
overtimeHours: Float
}
input CreateQuoteInfoInput {
id: ID
overtimeDetails: [OvertimeDetailInput]
}
input UpdateQuoteInfoInput {
id: ID!
overtimeDetails: [OvertimeDetailInput]
}
additionally tested this by migrating back to v1 then adding in improvepluralization
. Then performing a migrate to v2 and pushing it failed with the following error.
Reason: Schema Creation Status is FAILED with details: Found 2 problem(s) with the schema:
The input value type 'OvertimeDetailInput' is not present when resolving type 'CreateQuoteInfoInput' [@168:1].
The input value type 'OvertimeDetailInput' is not present when resolving type 'UpdateQuoteInfoInput' [@173:1].
This looks like a discrepancy between transformer processing and codegen libraries. Transferring to the codegen repo.
Hello @alharris-at
I'm experiencing the same issue. Trying to migrate to v2, schema migration goes well and when I'm trying to amplify push
it fails with the same error message. Any news on this bug?
I faced the same issue...capitalizing the first letter of your non model type in schema.graphql and then running "amplify api gql-compile" command fixes this issue.
I ran into this issue while upgrading to V2 as well. AWS documentation has always been pretty bad but this one is one of the worst. You can't make structural changes without documenting them. Not only was this not documented, but there were also no mentions of custom types in the V2 documentation. I was under the impression that it was removed in favor of AWSJSON.
Is there any update on this?
@Danish-karim Did you face any issue with appsync later on doing query or mutation on older data after you capitalized the type?
@DevTGhosh no