Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate schema #68

Closed
milessabin opened this issue Aug 14, 2020 · 4 comments · Fixed by #426
Closed

Validate schema #68

milessabin opened this issue Aug 14, 2020 · 4 comments · Fixed by #426
Labels
enhancement New feature or request

Comments

@milessabin
Copy link
Member

Currently there's no validation of schemas beyond basic syntactic well-formedness. Consequently it's possible to construct schemas with references to undefined types (typically due to a typo in the definition or use) or multiple definitions (eg. I've accidentally defined a first as a scalar then as an enum, but forgotten to remove the first definition). Invalid schemas of this sort can result in all sorts of confusing runtime failures later.

The GraphQL spec has a fairly comprehensive list of validation criteria for queries. The validation criteria for schemas is less explicit and spread throughout section 3 of the spec: https://spec.graphql.org/June2018/#sec-Type-System. In practice I think that checking for references to undefined or multiply defined types will cover the most common issues.

GraphQL schemas are represented as values of the Schema types and the validation above would be a matter of checking the NamedType elements of its types member for consistency and completeness.

@yasuba
Copy link
Collaborator

yasuba commented Aug 19, 2020

I've agreed with Miles to take a look at this issue.

@milessabin
Copy link
Member Author

Mostly done in #68.

There are a few additional things we could add. For instance checking that a object type defines all the members specified by the interfaces it implements.

@keirlawson
Copy link
Contributor

Was wondering what is left to do here? Happy to have a go at contributing further validation if there is more required.

@milessabin
Copy link
Member Author

I think probably needs a quick review of the spec before closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants