-
-
Notifications
You must be signed in to change notification settings - Fork 207
Add patch package to apply diff changes to schemas #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
69
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
69 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 441c198
Add directive usage; add tests
jdolle 288ae36
Improve path handling
jdolle f19e299
WIP: Print test schemas with directives.
jdolle 6cd0ba3
Support all directive usage cases
jdolle bab8b86
Remove unnecessary import
jdolle 62c16ba
Same
jdolle e546227
Simplify errors; add readme
jdolle a430f80
Remove redundant types; patch more descriptions and defaults etc
jdolle 450a572
Prettier
jdolle d23a3cb
Support more changes
jdolle 7cc882b
fix prettier etc
jdolle 26343fa
Improve error handling and error types
jdolle 39c2616
tweaking errors
jdolle 0cf0b11
More error fixes
jdolle 4d9bd95
Export lower level methods
jdolle 6b83adb
FieldAdded.addedFieldReturnType
jdolle 6f2756b
Fix operation type changes
jdolle 83dfa4e
Consistency; adjust schema operation type logic
jdolle 563b054
Export missing change types
jdolle f61c716
Change path for deprecated directives; fix duplicating deprecated dir…
jdolle 2a42993
Update seven-jars-yell.md
jdolle b415723
Repeatable directives are a nightmare
jdolle a6d80a3
Fix tests
jdolle cd3db7e
add more complicated tests that are needed for completeness
jdolle a8fc04d
support repeat directives. Fix argument mutual change
jdolle e791196
fix import
jdolle bcd9cef
Detailed changelog
jdolle 82e9bb7
Hide nested changes from CLI by default
jdolle c8a03d1
Move readme
jdolle 367f544
Add imports on patch on example
jdolle e51bbd7
Explain requireOldValueMatch
jdolle 4138969
Rename expectPatchToMatch
jdolle 9bffca4
prettier
jdolle 9972ac7
clarify option in types
jdolle 3c870c7
Add meta check to enum value removed
jdolle a89eec1
inputFieldAddedFromMeta non-breaking cases
jdolle ee61960
Adjust objectTypeInterfaceAddedFromMeta reason
jdolle 083528d
add path check on union patches
jdolle 15b957a
Fix tests; remove unique patch logic for deprecation
jdolle 9416576
Simplify nested conditions
jdolle 801f0e6
Mention not validating
jdolle 3ce91ba
Simplifying nested conditions
jdolle aa4ba82
Simplifying nested conditions
jdolle d1b076a
Simplifying nested conditions
jdolle 87b7f49
Simplifying nested conditions
jdolle 3215991
Make removing deprecation safe
jdolle e23fe3b
Use version 0.0.0 and add changeset to patch
jdolle c71a0e8
Adjust error handling
jdolle 5f76581
Fix description removed; move tests outside of src
jdolle 66a21cd
Add failure cases; fix field add error
jdolle bee17d0
fix removed reference
jdolle 4c697c0
Add edge case tests for directives
jdolle 91e35cd
Improve numerous error messages
jdolle 7450087
More error format improvements
jdolle af2cfad
Fix changelog
jdolle 408d59a
add fieldremoval to removal list
jdolle 78dc291
consistent missing values
jdolle d71a60a
Merge branch 'graphql-hive:master' into type-added-meta
jdolle 16a3374
Fix merge conflict
jdolle e123bc4
prettier
jdolle 0d81d03
Merge branch 'graphql-hive:master' into type-added-meta
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
Some comments aren't visible on the classic Files Changed page.
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 | ||
n1ru4l marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --- | ||
|
|
||
| "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); | ||
|
Collaborator
Author
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, | ||
| }); | ||
| } | ||
| }); | ||
jdolle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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.
Uh oh!
There was an error while loading. Please reload this page.