Skip to content

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