-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Find Breaking Changes: removed directives #1146
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
Find Breaking Changes: removed directives #1146
Conversation
src/utilities/findBreakingChanges.js
Outdated
const removedDirectives = []; | ||
|
||
oldSchema.getDirectives().forEach(directive => { | ||
if (!newSchema.getDirective(directive.name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This I believe makes this O(n^2): https://github.com/graphql/graphql-js/blob/master/src/type/schema.js#L206
A more efficient version, O(nlogn):
const newSchemaDirectiveNames = new Set(oldSchema.getDirectives().map(directive => directive.name));
oldSchema.getDirectives().forEach(directive => {
if (!newSchemaDirectiveNames.has(directive.name) {
...
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thanks @mjmahone !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Nice, this looks great! Thanks @kenleezle. Can you go ahead and update this PR to also include:
|
@leebyron CI is not running on my commits, can you ptal? |
src/type/directives.js
Outdated
@@ -74,6 +75,12 @@ export class GraphQLDirective { | |||
}); | |||
} | |||
} | |||
|
|||
getArgumentMap(): ObjMap<GraphQLArgument> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we want to add this to the Directive
class. It should be fine for findBreakingChanges
to just use the this.args
, and just use Array.find
when checking for the existence of an arg. I'm not too worried about performance given that there aren't usually many directives to begin with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was my initial instinct. @mjmahone is that ok with you since you originally raised the concern?
lol @sam-swarr you are going to love what i did with Schema::getDirectiveMap()
har har
@sam-swarr @mjmahone I think I addressed your comments to date. PTAL. Thanks! |
closed this and replaced it with #1152 in an attempt to debug the CI not running problem. |
Introduced a function to find removed directives, along with a simple unit test.