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 SDL directives #1435

Closed
wants to merge 4 commits into from
Closed

Validate SDL directives #1435

wants to merge 4 commits into from

Conversation

mjmahone
Copy link
Contributor

Re-uses the existing validateSchema to resolve #1389.

This is a sub-optimal solution: ideally we'd be doing validation purely on the AST, as @IvanGoncharov is working on. However, this gets us to a state where people aren't using directives illegally within the SDL, which should allow us to release them.

function validateDirectiveDefinitions(context: SchemaValidationContext): void {
// Ensure no directive is defined multiple times
const directiveDefinitions = new Map();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjmahone This change is make sense on it's own since you can manually construct GraphQLSchema with duplicated directives.
Can you extract this change into separate PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Map: all around this library, we use Object.create(null) for maps with strings as keys and Map for non-string keys. AFAIK Map have significantly lover performance, I'm also not sure about memory usage.

@mjmahone
Copy link
Contributor Author

#1438 is strictly better than this PR, so closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add validation of directives in SDL
3 participants