-
Notifications
You must be signed in to change notification settings - Fork 2.1k
findBreakingChanges tests: use buildSchema when possible #1406
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
findBreakingChanges tests: use buildSchema when possible #1406
Conversation
Instead of generating the schema by using the Type constructors, use buildSchema with the correct SDL for each test.
}, | ||
}); | ||
const directiveRemovedLocationOld = new GraphQLDirective({ | ||
name: '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 directive had incorrect name, according to the spec, spaces should not be allowed on directive name:
https://facebook.github.io/graphql/draft/#DirectiveDefinition
https://facebook.github.io/graphql/draft/#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.
👍
{ | ||
type: BreakingChangeType.DIRECTIVE_REMOVED, | ||
description: 'skip was removed', | ||
description: 'DirectiveThatIsRemoved was removed', |
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 was necessary since printSchema
does not print GraphQL default directives, so I've added a directive to test the same scenario.
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.
Makes sense 👍
{ | ||
type: BreakingChangeType.DIRECTIVE_REMOVED, | ||
description: `${GraphQLIncludeDirective.name} was removed`, | ||
description: `DirectiveThatIsRemoved was removed`, |
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.
Change made for the same motive than above, printSchema
does not print GraphQL default directives
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.
👍
locations: [DirectiveLocation.FIELD_DEFINITION], | ||
args: { | ||
arg1: { | ||
name: 'arg1', |
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.
FYI this was giving undefined
type to arg1
, so I've added something as type for that arg on the SDL below.
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.
👍
I have not changed the test Another point is that the test |
type Query { | ||
field1: String | ||
} |
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.
It's very hard to read when Query
is in the middle of SDL.
Looking at other tests it looks like the current convention is too put Query
as the last type. Can you please do the same in rest of tests?
@JCMais Thanks for PR 👍 |
@IvanGoncharov I've changed the ordering of the types, can you check again if it's more readable? |
const oldSchema = buildSchema(` | ||
type Type1 { | ||
field1( | ||
arg1: String, arg2: String, arg3: [String], arg4: String, arg5: String!, arg6: String!, arg7: [Int]!, |
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.
nit: one argument per line without commas would be consistent with prettier:
https://github.com/prettier/prettier/blob/master/tests/graphql_arguments/__snapshots__/jsfmt.spec.js.snap#L12-L16
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 for making these tests more readable! I had been doing this with my own tests for awhile, so it's great to see this clear improvement in the main repo. |
Instead of generating the schema by using the type constructors, this changes the tests to use
buildSchema
with the correct SDL for each test.Related to #1341
SDL was generated using the following code:
So it's based solely on how the previous
oldSchema
andnewSchema
of each test case were printed byprintSchema
.