Validate AppSync Code-First GraphQL Schema before deploying
See original GitHub issueI am using the code-first approach to constructing my GraphQL schema with @aws-cdk/aws-appsync
. I have noticed that the schemas errors are really vague when pushing new schema changes via CDK.
E.G the last error I got was:
Schema Creation Status is FAILED with details: Failed to parse schema document - ensure it's a valid SDL-formatted document.
I would love to be able to validate the schema before deployment or even print / save the schema to file as a test run. Its sometimes hard to spot mistakes when you are composing your schema using multiple files.
Use Case
We use AWS CDK and App Sync to build our GraphQL API. We need to be able to write the GraphQL schema reliably and test it before deploys.
Current Workaround
Currently, I am doing a console.log()
of the schema during deployment to try and spot issues.
- 👋 I may be able to implement this feature request
- ⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top GitHub Comments
This feature is a big part of the appsync experience (esp the code-first).
Currently, I’m thinking we would have to run a check on synthesis after the entire gql string is built out… Speaking top of mind, there are two parts to this issue: syntax and semantics.
The code-first model should protect against most syntactical errors. Since we are generating most of the actual output itself, as long as the construct isn’t generating bad code, our syntax issues should be assuaged. I’m sure there are probably some issues here and there that need to be resolved to make it more robust, but in theory, the code-first model should save us from syntax errors.
As for the more semantic problems, I think the
graphql
library itself has a ton of great resources for this.@MrArnoldPalmer how well-received would it be to add another package to the CDK dependencies?
EDIT
After looking into the graphql validation utilities , I think this is looking pretty good. In fact, I think the code snippet for this would be something along the lines of:
No guarantees this would work outside of the box, but it seems promising 😊
@BryanPan342 I think it would be received fine for this case. Definitely seems like something we prioritize 👍🏻