-
Notifications
You must be signed in to change notification settings - Fork 2k
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
#1341 findBreakingChanges to return line and column of the change #1889
base: main
Are you sure you want to change the base?
Conversation
@Carglass Thanks for PR 👍
I think it's better to just return whole graphql-js/src/language/source.js Lines 27 to 29 in e7c1fde
If a user needs to map Also, note that it should be an array of nodes since one type can be defined in multiple documents: let schema = buildSchema('type Query');
schema = extendSchema(schema, parse('extend type Query { foo: String }');
schema = extendSchema(schema, parse('extend type Query { bar: String }');
graphql-js/src/type/definition.js Line 669 in e7c1fde
and graphql-js/src/type/definition.js Line 670 in e7c1fde
So I need to think about what would be the best API design in this case. |
@IvanGoncharov Thanks for your detailed comments.
I have started working on adding astNodes instead of only lines and columns. So far, my main issue is that I have had to refactor the tests to assert each node one by one ( I cannot include the whole astNode in the deep equal test). I will ping you once I have added it everywhere. I will also wait for your input before working on returning an arrays including the potential extensions |
@Carglass Thanks for rebasing your changes on master. |
@IvanGoncharov No problem on my side to rebase, please let me know when you are done with your changes. Regarding this issue in itself, I am not happy with my tests so far, I would ideally need to be able to do snapshots to follow the style of the current tests. Do you think we could add a chai snapshot library for example? The issue is that the astNodes are usually big objects, alternatively I could serialize them into files manually, but using a snapshot utility seems more convenient and reusable in case of later changes |
// flow ensures that oldNode is of type ASTNode, checking its presence should be enough | ||
expect(findBreakingChanges(oldSchema, newSchema)[0]).to.have.property( | ||
'oldNode', | ||
); |
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.
You don't need snapshot here just check that node inside the change is the same as in in-memory schema:
expect(findBreakingChanges(oldSchema, newSchema)).to.deep.equal([
{
type: BreakingChangeType.TYPE_REMOVED,
description: 'Type1 was removed.',
oldNode: oldSchema.getType('Type1').astNode,
newNode: undefined,
},
]);
``
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.
Thank you, that is a smart way to solve my issue indeed. I will rework those tests this way!
@Carglass Thanks for the patience. I finished all the major refactoring that can be done without changing public API.
The main goal of this library is to be a reference implementation for other languages that's why we compromise the speed of development for code quality and better tests.
Please see my comment above for how to solve this without relying on snapshots. |
a9bc1c1
to
c1b1681
Compare
@IvanGoncharov I have implemented the astNodes for all Breaking and DangerousChanges. For now, it is only the "regular" nodes and not the extension nodes. Please let me know about the direction regarding the API for the extension nodes. Also, please let me know of any comment or improvement on the changes so far :) By the way, I rebased after your changes |
@Carglass I will try to take a look this weekends. |
linked to issue #1341
I saw that this issue has not received new pull requests for a while, or at least I dont think so. I am proposing an implementation to answer the feature request from issue #1341. So far, I have added fields in the Breaking Change types to give the locations of the change in the old schema and the new schema. they will be left empty if the schema was not generated from SDL. I also updated the tests so that they pass with the lines and columns for change added
I wanted to ask if the direction is good. More specifically, I felt like returning this in breaking changes could be an option, as well as returning the source schema strings (without which it is hard to find the location when the schema is declared inside a js file, for now I have not yet added it to BreakingChange).
For now, only findRemovedTypes is implemented, I will continue working on it if that fits the need,
Thanks for your comments