-
-
Notifications
You must be signed in to change notification settings - Fork 204
Diff returns all nested changes for additions #2893
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
Open
jdolle
wants to merge
8
commits into
graphql-hive:master
Choose a base branch
from
jdolle:type-added-meta
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cf7fcfc
major: diff includes all nested changes when a node is added
jdolle 2adf87b
Fix directive argument changes to match others
jdolle dfe87bf
Add rule to ignore nested additions
jdolle c3dcc73
Add a field test
jdolle 6fd13d2
Fix parent path; add more tests
jdolle 0cdcc17
TypeChanged changes
jdolle 985a146
prettier
jdolle 3f781fb
Add more meta to changes
jdolle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@graphql-inspector/core': major | ||
--- | ||
|
||
"diff" includes all nested changes when a node is added. Some change types have had additional meta fields added. | ||
On deprecation add with a reason, a separate "fieldDeprecationReasonAdded" change is no longer included. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,54 @@ import { CriticalityLevel, diff, DiffRule } from '../../src/index.js'; | |
import { findFirstChangeByPath } from '../../utils/testing.js'; | ||
|
||
describe('enum', () => { | ||
test('added', async () => { | ||
const a = buildSchema(/* GraphQL */ ` | ||
type Query { | ||
fieldA: String | ||
} | ||
`); | ||
|
||
const b = buildSchema(/* GraphQL */ ` | ||
type Query { | ||
fieldA: String | ||
} | ||
|
||
enum enumA { | ||
""" | ||
A is the first letter in the alphabet | ||
""" | ||
A | ||
B | ||
} | ||
`); | ||
|
||
const changes = await diff(a, b); | ||
expect(changes.length).toEqual(4); | ||
|
||
{ | ||
const change = findFirstChangeByPath(changes, 'enumA'); | ||
expect(change.meta).toMatchObject({ | ||
addedTypeKind: 'EnumTypeDefinition', | ||
addedTypeName: 'enumA', | ||
}); | ||
expect(change.criticality.level).toEqual(CriticalityLevel.NonBreaking); | ||
expect(change.criticality.reason).not.toBeDefined(); | ||
expect(change.message).toEqual(`Type 'enumA' was added`); | ||
} | ||
|
||
{ | ||
const change = findFirstChangeByPath(changes, 'enumA.A'); | ||
expect(change.criticality.level).toEqual(CriticalityLevel.NonBreaking); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test shows that enum additions also contain all nested changes within that enum, and that those changes are flagged as non-breaking. |
||
expect(change.criticality.reason).not.toBeDefined(); | ||
expect(change.message).toEqual(`Enum value 'A' was added to enum 'enumA'`); | ||
expect(change.meta).toMatchObject({ | ||
addedEnumValueName: 'A', | ||
enumName: 'enumA', | ||
addedToNewType: true, | ||
}); | ||
} | ||
}); | ||
|
||
test('value added', async () => { | ||
const a = buildSchema(/* GraphQL */ ` | ||
type Query { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 could be convinced that this is a minor patch because the changes to the output's format doesnt break anything. But the actual content of the changes has changed drastically which is why I thought we should be safe and declare a major change.