aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
89 stars 78 forks source link

Creation Status is FAILED with details: Internal Failure while saving the schema. #1362

Open zirkelc opened 1 year ago

zirkelc commented 1 year ago

How did you install the Amplify CLI?

npm install -g

If applicable, what version of Node.js are you using?

v18.14.1

Amplify CLI Version

11.0.2

What operating system are you using?

macOS

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Describe the bug

If the Schema contains an input type, all nested fields must also be defined as input types. That is the official GraphQL standard.

This Schema is therefore invalid:

type Mutation {
  test(input: TestInput!): Test 
}

# -> input type can only contain scalars (String, Int, ...) and other input types
input TestInput {
  nested: NestedTestInput!
}

# -> error: should be defined as input type
type NestedTestInput {
  id: ID
  name: String!
}

However, when this Amplify project is pushed, it fails with the following error:

🛑 The following resources failed to deploy: Resource Name: GraphQLAPITransformerSchema3CB2AE18 (AWS::AppSync::GraphQLSchema) Event Type: update Reason: Schema Creation Status is FAILED with details: Internal Failure while saving the schema. URL: ...

🛑 Resource is not in the state stackUpdateComplete Name: GraphQLAPITransformerSchema3CB2AE18 (AWS::AppSync::GraphQLSchema), Event Type: update, Reason: > > Schema Creation Status is FAILED with details: Internal Failure while saving the schema.

2023-03-23_14-56-26

This error is quite confusing, because it very difficult to figure out the actual issue. There is another seemingly unrelated issue: https://github.com/aws-amplify/amplify-category-api/issues/1040

Expected behavior

Validate Schema before deployment and show error message that Schema is invalid, for example:

Input type TestInput contains non-input type NestedTestInput on field nested

Reproduction steps

  1. Clone repository: https://github.com/zirkelc/amplify-nested-input-issue
  2. Leave NestedTestInput type commented out
  3. Push to cloud to created stack with amplify push -y
  4. Remove comments for NestedTestInput and nested
  5. Push to cloud again with amplify push -y

Project Identifier

768325cc35028974c561f7d416d382b3

Log output

``` # Put your logs below this line ```

Additional information

No response

Before submitting, please confirm:

AnilMaktala commented 1 year ago

Hi @zirkelc, Thank you for raising this. After following the steps provided, I have been able to reproduce this issue and I fully concur with your observation that the error message displayed is not useful for the developers. Therefore, I will label this as a bug that needs further evaluation by the team.

image

Lekha30 commented 1 year ago

I am also facing this issue. Any updates on this please?