https://serverless-stack.com/ logo
#sst
Title
# sst
d

David Martin

08/10/2021, 9:11 PM
What do you think about adding GraphQL schema validation to the AppSyncApi construct so that errors cause it to fail locally instead of waiting a few minutes for it to be deployed to AWS and getting the error there. The code should be pretty simple:
const parseSchema = require("graphql/language").parse;
try {
parseSchema(graphQLSchemaAsString);
} catch (e) {
// parse failed
}
t

thdxr

08/10/2021, 9:12 PM
I'm not super savvy with gql so I'll let frank or jay share their thoughts
d

David Martin

08/10/2021, 9:18 PM
in my previous project, i created a little CLI wrapper that would run some validation prior to deployment and that included parsing the graphql schema. validating that schema locally saves a lot of time.
f

Frank

08/10/2021, 9:48 PM
Hey @David Martin, yeah makes sense. Just created an issue for this https://github.com/serverless-stack/serverless-stack/issues/675
Like Dax, I’m not super savvy either 😁 it’d be really helpful if u could share a couple of invalid schema examples that should get caught by the check.
I will add them to the tests after I put this in.
d

David Martin

08/10/2021, 9:53 PM
no problem. i don’t mean to brag, but i’m really good at making invalid schemas. i have so many from today alone!
Ok, added a valid and an invalid schema. Actually I haven’t run validation on the valid schema but it’s so simple that I’m pretty confident it passes. If it doesn’t, lmk and I’ll fix it. I didn’t add >1 invalid schemas bc as long as you catch one failure, you’ll get them all. Thanks @Frank! Update: I went ahead and validated the “valid” schema. There was an error in the valid schema, I fixed it and re-uploaded to the github issue. As I said, I’m great at invalid schemas.
f

Frank

08/11/2021, 3:44 AM
LOL nice! I will put this in this week.
Hey @David Martin, parsing the invalid schema you shared in the issue that was missing
PostInput
didn’t throw an error. It was able to parse the Document.
d

David Martin

08/16/2021, 7:32 PM
Odd. Ok, I will look into this and find the problem.
2 Views