-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
chore(tests): cleaner GraphQL schema snapshots #533
chore(tests): cleaner GraphQL schema snapshots #533
Conversation
fd75dc3
to
a324f26
Compare
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.
Awesome; let's DRY it up and then it's good to merge I think! This makes the test files so much nicer, and now I can literally link people to them as example GraphQL schemas without backslashes everywhere which is just beautiful - thanks again! 🎉
05012a4
to
bc68faf
Compare
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.
Looking good; just need to undo the schema sorting 👍
packages/graphile-build/__tests__/__snapshots__/emptyMutation.test.js.snap
Outdated
Show resolved
Hide resolved
packages/postgraphile-core/__tests__/integration/schema/core.js
Outdated
Show resolved
Hide resolved
8c5d45a
to
e1aff3d
Compare
727a195
to
66700c6
Compare
c7beacd
to
414a6ef
Compare
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.
Awesome; this makes the snapshots a hell of a lot more readable 👍
The exclusive input argument for this mutation. An object type, make sure to see documentation for this object’s fields. | ||
""" | ||
input: JsonIdentityMutationInput! | ||
): JsonIdentityMutationPayload |
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 has been reordered I think?
EDIT: ah, it's because my old schema sorter and GraphQL's differ slightly. This is fine.
Wow, this is awesome! But why don't you want to sort schemas by default? Btw, in my own project I even omit field descriptions from the schema to get an even cleaner snapshot diff: import { GraphQLSchema, buildASTSchema, lexicographicSortSchema, parse, printSchema, visit } from 'graphql';
const simplified: GraphQLSchema = lexicographicSortSchema(buildASTSchema(visit(parse(printSchema(schema)), {
StringValue(node, key) {
return key == 'description' ? null : node;
}
}))); Might be interesting to provide as an option. |
@ab-pm: quoting @benjie's resolved comment:
Unfortunately, I don't think that Jest snapshot matchers can expose a configuration interface, so there's no way to provide an option to change these. However, if I'm wrong, then feel free to file an issue on the repository suggesting this change -- or even better, send a pull request! 😄 |
Thanks, I had not seen that. Yeah, it seems Jest snapshot serialisers are not configurable, unless you add them explicitly with |
The field order is officially significant (Lee Byron himself states so); so by default we should honour it. |
Same change as in graphile-contrib/pg-many-to-many#27