aws / aws-appsync-community

The AWS AppSync community
https://aws.amazon.com/appsync
Apache License 2.0
506 stars 32 forks source link

Reserved graphql schema keywords? #108

Closed madjake closed 2 years ago

madjake commented 4 years ago

Is there a published list of reserved schema keywords? If there isn't can one be provided here and added to relevant documentation please?

Some context behind the question:

We've run into issues where amplify fails to push the new schema and complains about a syntax problem but when we run it through a validator it's clean.

We ended up narrowing it down to a type field named body that was failing the deployments with an obtuse syntax error.

akalin81 commented 4 years ago

Recap to help out in the future with this issue: we were getting this ‘Expected Name, found (’ error when trying to push Graph changes.. The weird behavior is that your changes go up to Appsync without an issue, but amplify will fail in post clean up and break the pipeline. So even though your changes are pushed and working, the build will fail. When we encountered this issue before, I found out that it was due to a reserved word that we used in schema body ..so when we were getting the same error, I assumed it was the same issue, and went through all the items i added for about 8 hours trial and error of pushing them.

the conclusion:.. its not a reserved keyword issue this time…It was failing because our response on the aggregate query returns 4 levels deep of custom objects…It kept failing on the custom object on 4th level… but the weird part was that we have other queries with 5 level depth and custom object!… The issue was that amplify for some reason requires that you have String values in your custom objects if you are going deep… so i added fake `id: String’ to all custom objects.. and it works…

Point of the story is, AWS Amplify, PLEASE provide better errors! Failing with 'Expected Name, found (' for everything is not acceptable!

phi-line commented 4 years ago

To save others time in the future...

app is a reserved keyword as well.

Not Authorized to access app on type AppsList

AppSync team, can we have a list of Reserved Keywords properly documented?

jeremylumanbailey commented 3 years ago

It would be nice to have clear layout of reserved words. I'm still pretty new when it comes to AWS products in general, but I have had a hard time distinguishing what belongs to what category (to be fair I am new to NoSQL as well). Such as allot of the graqphQL schema is filled with DynamoDB reserved words I had someone point out to me such as the input ModelIntInput { ne: Int eq: Int le: Int lt: Int ge: Int gt: Int between: [Int] attributeExists: Boolean attributeType: ModelAttributeTypes } example uses allot of DynamoDB reserved words I found here https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html but also found the conditions for it here https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html only thing I was able to find for AWS GraphQL specifically was on this page https://docs.aws.amazon.com/appsync/latest/devguide/scalars.html#graphql-scalars
but it only lists scalars and I am not sure if there is anything else.

pj-ojas commented 3 years ago

Any help in this question?. I am keep landing in the following same issue time to tome. Schema Creation Status is FAILED with details: Schema has the following errors: - Type name begins with a reserved word. I cleaned up my schema not to include any dynamoDB reserved words. But I am not sure which table and which field the error is referring to. At times amplify push just works without any complaints and some times it just blocks me to push new updates.

Please help

chrisyeung1121 commented 3 years ago

Same for me @pj-ojas - What's annoying was that the Stack is not stuck and cannot be rollbacked nor updated.

When it states Type name begins with a reserved word. - I started by looking into DynamoDB's long list of reserved words and found that things like NAME, STATUS .. are all in the reserved words list.

But If you simply bootstrap a appsync api via amplify add api, the Todo model that it provided already has name in it. So I tried to look at another angle, and see it says Type name, begins with a reserved words. I start to believe that the reserved words list are actually from Appsync, but there are no existing documentation on what exists as a reserved word in appsync..

Waiting for help.

chrisyeung1121 commented 3 years ago

I found out what happened in mine. I had a custom type named AWSAmplify. and violated the reserved words according to this - https://docs.aws.amazon.com/appsync/latest/devguide/scalars.html

rhorohit commented 3 years ago

I am using a type name AWSMail in my project. I pushed the changes multiple times without any error. But from the last couple of days, I am getting below error.... "Resource Name: o3.......oxfqliupuGraphQLSchema (AWS::AppSync::GraphQLSchema) Event Type: create Reason: Schema Creation Status is FAILED with details: Schema has the following errors:

× An error occurred when pushing the resources to the cloud"

Anything changed recently?

jsteenkamp commented 3 years ago

I'm having similar issues to those described above. I have a production app that has been fine. I want to add additional fields in the schema: regions: [String] this passes schema validation but amplify push resulted in the stack being stuck in UPDATE_ROLLBACK_FAILED for a nested stack, for the schema, under the root stack. None of the rollback options are successful. Now I'm concerned about pushing any changes to production - even if it works in dev it may not in prod.

I ensure that I am always using the current version of the Amplify CLI. I updated the CLI before above issue (v4.44.0). This caused other problems as the CLI status command reported initial report OK and then failed with Error - Cannot find module jsonschema. I eventually deleted the CLI (via npm), deleted any remaining CLI files in /usr/local/lib/node_modules/@aws-amplify/cli and then reinstalled via npm i -g @aws-amplify/cli this worked.

jsteenkamp commented 3 years ago

I managed to recover and ROLLBACK successfully. The issue was that the nested stack that generates the GraphQLSchema could not rollback. The reason is that I had a type prefixed with AWS which is a reserved prefix by AppSync.

Note that this schema had complied and the application deployed successfully for some time - so stricter validation of the schema must have been implemented by AWS since.

The problem now was to get the schema for the nested stack correct so that the rollback could proceed. I edited the associated graphql.schema in the S3 deployment bucket under amplify-appsync-files (downloaded file, edit, upload to bucket replacing original).

I then rolled back the root stack and everything completed - all green.

I could then again amplify push from the Amplify CLI.

The good news is "it was me" and not Amplify, and I know more about how to recover when CloudFormation stack fails.

The Amplify/AppSync GraphQL validation should catch these type errors.

jpignata commented 2 years ago

Hi all! AppSync does reserve the namespace beginning with AWS, which is likely what you're encountering. This is documented here: https://docs.aws.amazon.com/appsync/latest/devguide/scalars.html -- please reach out if you're having further issues or have any follow up questions.