Skip to content

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

Closed

Conversation

kenleezle
Copy link
Contributor

@kenleezle kenleezle commented Dec 14, 2017

Introduced a function to find removed directives, along with a simple unit test.

@kenleezle kenleezle changed the title Find removed directives Find Breaking Changes: removed directives Dec 14, 2017
const removedDirectives = [];

oldSchema.getDirectives().forEach(directive => {
if (!newSchema.getDirective(directive.name)) {
Copy link
Contributor

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) {
    ...
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 thanks @mjmahone !

Copy link
Contributor Author

@kenleezle kenleezle Dec 14, 2017

Choose a reason for hiding this comment

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

updated

@sam-swarr
Copy link
Contributor

Nice, this looks great! Thanks @kenleezle.

Can you go ahead and update this PR to also include:

  • if a directive argument is removed
  • if a non-nullable directive argument is added
  • if a directive location is removed

@kenleezle kenleezle changed the title Find Breaking Changes: removed directives [WIP] Find Breaking Changes: removed directives Dec 15, 2017
@kenleezle
Copy link
Contributor Author

@leebyron CI is not running on my commits, can you ptal?

@@ -74,6 +75,12 @@ export class GraphQLDirective {
});
}
}

getArgumentMap(): ObjMap<GraphQLArgument> {
Copy link
Contributor

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.

Copy link
Contributor Author

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

@kenleezle kenleezle changed the title [WIP] Find Breaking Changes: removed directives Find Breaking Changes: removed directives Dec 15, 2017
@kenleezle
Copy link
Contributor Author

@sam-swarr @mjmahone I think I addressed your comments to date. PTAL. Thanks!

@kenleezle kenleezle closed this Dec 15, 2017
@kenleezle
Copy link
Contributor Author

closed this and replaced it with #1152 in an attempt to debug the CI not running problem.

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.

4 participants