graphql-schema_comparator 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +5 -2
- data/CHANGELOG.md +10 -0
- data/README.md +1 -1
- data/gemfiles/graphql-head.gemfile +5 -0
- data/gemfiles/graphql1.10.gemfile +5 -0
- data/gemfiles/graphql1.13.gemfile +5 -0
- data/graphql-schema_comparator.gemspec +10 -5
- data/lib/graphql/schema_comparator/changes/criticality.rb +1 -1
- data/lib/graphql/schema_comparator/changes.rb +62 -63
- data/lib/graphql/schema_comparator/diff/argument.rb +1 -1
- data/lib/graphql/schema_comparator/diff/directive.rb +2 -2
- data/lib/graphql/schema_comparator/diff/directive_argument.rb +1 -1
- data/lib/graphql/schema_comparator/diff/field.rb +3 -3
- data/lib/graphql/schema_comparator/diff/input_field.rb +1 -1
- data/lib/graphql/schema_comparator/diff/input_object.rb +2 -2
- data/lib/graphql/schema_comparator/diff/interface.rb +13 -13
- data/lib/graphql/schema_comparator/diff/object_type.rb +7 -7
- data/lib/graphql/schema_comparator/diff/schema.rb +9 -9
- data/lib/graphql/schema_comparator/diff/union.rb +1 -1
- data/lib/graphql/schema_comparator/version.rb +1 -1
- metadata +21 -9
- data/lib/graphql/schema_comparator/diff/has_directives.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbc98aaf530ce8c60dc291eac091f735180bedd7962f4229d6fc9ad19fcf02a9
|
4
|
+
data.tar.gz: e80de95b6b466297e8c69679cd2f4590f7bc77072573df004b0c8e266e06a9ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22b0ef77facfe02f84f0d14004c4576d415d9b3c4b3fe46d06ed0a3750ea302180217c1aec1b54cdefd0517f66a0f89a61789643ad66031766205cc03e95459f
|
7
|
+
data.tar.gz: 4e2251295877a04cfa6e15654470db736a52bda927be70dc0d3846e358d6d6d7d11553a04bfff383eb460d62b466bcb7610d3bb84d16fb613418af8d7884df4c
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
name: Tests
|
2
2
|
|
3
3
|
on:
|
4
|
-
push
|
4
|
+
- push
|
5
|
+
- pull_request
|
5
6
|
|
6
7
|
jobs:
|
7
8
|
test:
|
@@ -10,11 +11,13 @@ jobs:
|
|
10
11
|
fail-fast: false
|
11
12
|
matrix:
|
12
13
|
ruby: [2.4, 2.7, '3.0']
|
14
|
+
gemfile: [graphql1.10, graphql1.13, graphql-head]
|
15
|
+
env:
|
16
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
13
17
|
steps:
|
14
18
|
- uses: actions/checkout@v2
|
15
19
|
- uses: ruby/setup-ruby@v1
|
16
20
|
with:
|
17
21
|
bundler-cache: true
|
18
22
|
ruby-version: ${{ matrix.ruby }}
|
19
|
-
- run: bundle install
|
20
23
|
- run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.1.0 (December 20 2021)
|
4
|
+
|
5
|
+
### Bug Fix
|
6
|
+
|
7
|
+
- Adding non-null arguments with a default value should be non-breaking (#38)
|
8
|
+
|
9
|
+
### New Features
|
10
|
+
|
11
|
+
- Remove legacy `graphql` gem API usage and support versions >= 1.13 (#46)
|
12
|
+
|
3
13
|
## 1.0.1 (May 26 2021)
|
4
14
|
|
5
15
|
### Bug Fix
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# GraphQL::SchemaComparator
|
2
2
|
|
3
|
-
|
3
|
+

|
4
4
|
|
5
5
|
`GraphQL::SchemaComparator` is a GraphQL Schema comparator. What does that mean? `GraphQL::SchemaComparator` takes
|
6
6
|
two GraphQL schemas and outputs a list of changes between versions. This is useful for many things:
|
@@ -8,20 +8,25 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = GraphQL::SchemaComparator::VERSION
|
9
9
|
spec.authors = ["Marc-Andre Giroux"]
|
10
10
|
spec.email = ["mgiroux0@gmail.com"]
|
11
|
-
|
12
11
|
spec.summary = %q{Compare GraphQL schemas and get the changes that happened.}
|
13
|
-
spec.description = %q{GraphQL::SchemaComparator compares two GraphQL schemas given their
|
14
|
-
spec.homepage = "
|
12
|
+
spec.description = %q{GraphQL::SchemaComparator compares two GraphQL schemas given their SDL and returns a list of changes.}
|
13
|
+
spec.homepage = "https://github.com/xuorig/graphql-schema_comparator"
|
15
14
|
spec.license = "MIT"
|
16
|
-
|
15
|
+
spec.metadata = {
|
16
|
+
"homepage_uri" => "https://github.com/xuorig/graphql-schema_comparator",
|
17
|
+
"changelog_uri" => "https://github.com/xuorig/graphql-schema_comparator/blob/master/CHANGELOG.md",
|
18
|
+
"source_code_uri" => "https://github.com/xuorig/graphql-schema_comparator",
|
19
|
+
"bug_tracker_uri" => "https://github.com/xuorig/graphql-schema_comparator/issues",
|
20
|
+
}
|
17
21
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
22
|
f.match(%r{^(test|spec|features)/})
|
19
23
|
end
|
24
|
+
|
20
25
|
spec.bindir = "bin"
|
21
26
|
spec.executables = ["graphql-schema", "schema_comparator"]
|
22
27
|
spec.require_paths = ["lib"]
|
23
28
|
|
24
|
-
spec.add_dependency "graphql", "
|
29
|
+
spec.add_dependency "graphql", ">= 1.10", "< 3.0"
|
25
30
|
spec.add_dependency "thor", ">= 0.19", "< 2.0"
|
26
31
|
spec.add_dependency "bundler", ">= 1.14"
|
27
32
|
|
@@ -51,11 +51,11 @@ module GraphQL
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def message
|
54
|
-
"Type `#{removed_type.
|
54
|
+
"Type `#{removed_type.graphql_name}` was removed"
|
55
55
|
end
|
56
56
|
|
57
57
|
def path
|
58
|
-
removed_type.
|
58
|
+
removed_type.path
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -88,11 +88,11 @@ module GraphQL
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def message
|
91
|
-
"`#{old_type.
|
91
|
+
"`#{old_type.graphql_name}` kind changed from `#{old_type.kind}` to `#{new_type.kind}`"
|
92
92
|
end
|
93
93
|
|
94
94
|
def path
|
95
|
-
old_type.
|
95
|
+
old_type.path
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -108,11 +108,11 @@ module GraphQL
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def message
|
111
|
-
"Enum value `#{enum_value.graphql_name}` was removed from enum `#{enum_type.
|
111
|
+
"Enum value `#{enum_value.graphql_name}` was removed from enum `#{enum_type.graphql_name}`"
|
112
112
|
end
|
113
113
|
|
114
114
|
def path
|
115
|
-
|
115
|
+
enum_value.path
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -128,11 +128,11 @@ module GraphQL
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def message
|
131
|
-
"Union member `#{union_member.graphql_name}` was removed from Union type `#{union_type.
|
131
|
+
"Union member `#{union_member.graphql_name}` was removed from Union type `#{union_type.graphql_name}`"
|
132
132
|
end
|
133
133
|
|
134
134
|
def path
|
135
|
-
union_type.
|
135
|
+
union_type.path
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -148,11 +148,11 @@ module GraphQL
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def message
|
151
|
-
"Input field `#{field.graphql_name}` was removed from input object type `#{input_object_type.
|
151
|
+
"Input field `#{field.graphql_name}` was removed from input object type `#{input_object_type.graphql_name}`"
|
152
152
|
end
|
153
153
|
|
154
154
|
def path
|
155
|
-
|
155
|
+
field.path
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
@@ -169,11 +169,11 @@ module GraphQL
|
|
169
169
|
end
|
170
170
|
|
171
171
|
def message
|
172
|
-
"Argument `#{argument.graphql_name}: #{argument.type.
|
172
|
+
"Argument `#{argument.graphql_name}: #{argument.type.graphql_name}` was removed from field `#{object_type.graphql_name}.#{field.graphql_name}`"
|
173
173
|
end
|
174
174
|
|
175
175
|
def path
|
176
|
-
|
176
|
+
argument.path
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
@@ -233,11 +233,11 @@ module GraphQL
|
|
233
233
|
end
|
234
234
|
|
235
235
|
def message
|
236
|
-
"Field `#{field.graphql_name}` was removed from object type `#{object_type.
|
236
|
+
"Field `#{field.graphql_name}` was removed from object type `#{object_type.graphql_name}`"
|
237
237
|
end
|
238
238
|
|
239
239
|
def path
|
240
|
-
[object_type.
|
240
|
+
[object_type.graphql_name, field.graphql_name].join(".")
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
@@ -271,11 +271,11 @@ module GraphQL
|
|
271
271
|
end
|
272
272
|
|
273
273
|
def message
|
274
|
-
"`#{object_type.
|
274
|
+
"`#{object_type.graphql_name}` object type no longer implements `#{interface.graphql_name}` interface"
|
275
275
|
end
|
276
276
|
|
277
277
|
def path
|
278
|
-
object_type.
|
278
|
+
object_type.path
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
@@ -291,7 +291,7 @@ module GraphQL
|
|
291
291
|
end
|
292
292
|
|
293
293
|
def message
|
294
|
-
"Field `#{
|
294
|
+
"Field `#{old_field.path}` changed type from `#{old_field.type.to_type_signature}` to `#{new_field.type.to_type_signature}`"
|
295
295
|
end
|
296
296
|
|
297
297
|
def criticality
|
@@ -303,7 +303,7 @@ module GraphQL
|
|
303
303
|
end
|
304
304
|
|
305
305
|
def path
|
306
|
-
|
306
|
+
old_field.path
|
307
307
|
end
|
308
308
|
end
|
309
309
|
|
@@ -329,11 +329,11 @@ module GraphQL
|
|
329
329
|
end
|
330
330
|
|
331
331
|
def message
|
332
|
-
"Input field `#{
|
332
|
+
"Input field `#{path}` changed type from `#{old_input_field.type.to_type_signature}` to `#{new_input_field.type.to_type_signature}`"
|
333
333
|
end
|
334
334
|
|
335
335
|
def path
|
336
|
-
|
336
|
+
old_input_field.path
|
337
337
|
end
|
338
338
|
end
|
339
339
|
|
@@ -360,12 +360,12 @@ module GraphQL
|
|
360
360
|
end
|
361
361
|
|
362
362
|
def message
|
363
|
-
"Type for argument `#{new_argument.graphql_name}` on field `#{
|
364
|
-
" from `#{old_argument.type.
|
363
|
+
"Type for argument `#{new_argument.graphql_name}` on field `#{field.path}` changed"\
|
364
|
+
" from `#{old_argument.type.to_type_signature}` to `#{new_argument.type.to_type_signature}`"
|
365
365
|
end
|
366
366
|
|
367
367
|
def path
|
368
|
-
|
368
|
+
old_argument.path
|
369
369
|
end
|
370
370
|
end
|
371
371
|
|
@@ -390,7 +390,7 @@ module GraphQL
|
|
390
390
|
|
391
391
|
def message
|
392
392
|
"Type for argument `#{new_argument.graphql_name}` on directive `#{directive.graphql_name}` changed"\
|
393
|
-
" from `#{old_argument.type.
|
393
|
+
" from `#{old_argument.type.to_type_signature}` to `#{new_argument.type.to_type_signature}`"
|
394
394
|
end
|
395
395
|
|
396
396
|
def path
|
@@ -452,15 +452,15 @@ module GraphQL
|
|
452
452
|
|
453
453
|
def message
|
454
454
|
if old_argument.default_value.nil? || old_argument.default_value == :__no_default__
|
455
|
-
"Default value `#{new_argument.default_value}` was added to argument `#{new_argument.graphql_name}` on field `#{
|
455
|
+
"Default value `#{new_argument.default_value}` was added to argument `#{new_argument.graphql_name}` on field `#{field.path}`"
|
456
456
|
else
|
457
|
-
"Default value for argument `#{new_argument.graphql_name}` on field `#{
|
457
|
+
"Default value for argument `#{new_argument.graphql_name}` on field `#{field.path}` changed"\
|
458
458
|
" from `#{old_argument.default_value}` to `#{new_argument.default_value}`"
|
459
459
|
end
|
460
460
|
end
|
461
461
|
|
462
462
|
def path
|
463
|
-
|
463
|
+
old_argument.path
|
464
464
|
end
|
465
465
|
end
|
466
466
|
|
@@ -478,12 +478,12 @@ module GraphQL
|
|
478
478
|
end
|
479
479
|
|
480
480
|
def message
|
481
|
-
"Input field `#{
|
481
|
+
"Input field `#{path}` default changed"\
|
482
482
|
" from `#{old_field.default_value}` to `#{new_field.default_value}`"
|
483
483
|
end
|
484
484
|
|
485
485
|
def path
|
486
|
-
|
486
|
+
old_field.path
|
487
487
|
end
|
488
488
|
end
|
489
489
|
|
@@ -523,11 +523,11 @@ module GraphQL
|
|
523
523
|
end
|
524
524
|
|
525
525
|
def message
|
526
|
-
"Enum value `#{enum_value.graphql_name}` was added to enum `#{enum_type.
|
526
|
+
"Enum value `#{enum_value.graphql_name}` was added to enum `#{enum_type.graphql_name}`"
|
527
527
|
end
|
528
528
|
|
529
529
|
def path
|
530
|
-
|
530
|
+
enum_value.path
|
531
531
|
end
|
532
532
|
end
|
533
533
|
|
@@ -544,11 +544,11 @@ module GraphQL
|
|
544
544
|
end
|
545
545
|
|
546
546
|
def message
|
547
|
-
"Union member `#{union_member.graphql_name}` was added to Union type `#{union_type.
|
547
|
+
"Union member `#{union_member.graphql_name}` was added to Union type `#{union_type.graphql_name}`"
|
548
548
|
end
|
549
549
|
|
550
550
|
def path
|
551
|
-
union_type.
|
551
|
+
union_type.path
|
552
552
|
end
|
553
553
|
end
|
554
554
|
|
@@ -565,11 +565,11 @@ module GraphQL
|
|
565
565
|
end
|
566
566
|
|
567
567
|
def message
|
568
|
-
"`#{object_type.
|
568
|
+
"`#{object_type.graphql_name}` object implements `#{interface.graphql_name}` interface"
|
569
569
|
end
|
570
570
|
|
571
571
|
def path
|
572
|
-
object_type.
|
572
|
+
object_type.path
|
573
573
|
end
|
574
574
|
end
|
575
575
|
|
@@ -579,8 +579,8 @@ module GraphQL
|
|
579
579
|
attr_reader :input_object_type, :field, :criticality
|
580
580
|
|
581
581
|
def initialize(input_object_type, field)
|
582
|
-
@criticality = if field.type.non_null?
|
583
|
-
Changes::Criticality.breaking(reason: "Adding a non-null field to an existing input type will cause existing queries that use this input type to error because they will not provide a value for this new field.")
|
582
|
+
@criticality = if field.type.non_null? && !field.default_value?
|
583
|
+
Changes::Criticality.breaking(reason: "Adding a non-null input field without a default value to an existing input type will cause existing queries that use this input type to error because they will not provide a value for this new field.")
|
584
584
|
else
|
585
585
|
Changes::Criticality.non_breaking
|
586
586
|
end
|
@@ -590,11 +590,11 @@ module GraphQL
|
|
590
590
|
end
|
591
591
|
|
592
592
|
def message
|
593
|
-
"Input field `#{field.graphql_name}` was added to input object type `#{input_object_type.
|
593
|
+
"Input field `#{field.graphql_name}` was added to input object type `#{input_object_type.graphql_name}`"
|
594
594
|
end
|
595
595
|
|
596
596
|
def path
|
597
|
-
|
597
|
+
field.path
|
598
598
|
end
|
599
599
|
end
|
600
600
|
|
@@ -602,8 +602,8 @@ module GraphQL
|
|
602
602
|
attr_reader :type, :field, :argument, :criticality
|
603
603
|
|
604
604
|
def initialize(type, field, argument)
|
605
|
-
@criticality = if argument.type.non_null?
|
606
|
-
Changes::Criticality.breaking(reason: "Adding a required argument to an existing field is a breaking change because it will cause existing uses of this field to error.")
|
605
|
+
@criticality = if argument.type.non_null? && !argument.default_value?
|
606
|
+
Changes::Criticality.breaking(reason: "Adding a required argument without a default value to an existing field is a breaking change because it will cause existing uses of this field to error.")
|
607
607
|
else
|
608
608
|
Changes::Criticality.non_breaking
|
609
609
|
end
|
@@ -614,11 +614,11 @@ module GraphQL
|
|
614
614
|
end
|
615
615
|
|
616
616
|
def message
|
617
|
-
"Argument `#{argument.graphql_name}: #{argument.type.
|
617
|
+
"Argument `#{argument.graphql_name}: #{argument.type.graphql_name}` added to field `#{field.path}`"
|
618
618
|
end
|
619
619
|
|
620
620
|
def path
|
621
|
-
|
621
|
+
argument.path
|
622
622
|
end
|
623
623
|
end
|
624
624
|
|
@@ -631,11 +631,11 @@ module GraphQL
|
|
631
631
|
end
|
632
632
|
|
633
633
|
def message
|
634
|
-
"Type `#{type.
|
634
|
+
"Type `#{type.graphql_name}` was added"
|
635
635
|
end
|
636
636
|
|
637
637
|
def path
|
638
|
-
type.
|
638
|
+
type.path
|
639
639
|
end
|
640
640
|
end
|
641
641
|
|
@@ -666,11 +666,11 @@ module GraphQL
|
|
666
666
|
end
|
667
667
|
|
668
668
|
def message
|
669
|
-
"Description `#{old_type.description}` on type `#{old_type.
|
669
|
+
"Description `#{old_type.description}` on type `#{old_type.graphql_name}` has changed to `#{new_type.description}`"
|
670
670
|
end
|
671
671
|
|
672
672
|
def path
|
673
|
-
old_type.
|
673
|
+
old_type.path
|
674
674
|
end
|
675
675
|
end
|
676
676
|
|
@@ -685,12 +685,12 @@ module GraphQL
|
|
685
685
|
end
|
686
686
|
|
687
687
|
def message
|
688
|
-
"Description for enum value `#{
|
688
|
+
"Description for enum value `#{new_enum_value.path}` changed from " \
|
689
689
|
"`#{old_enum_value.description}` to `#{new_enum_value.description}`"
|
690
690
|
end
|
691
691
|
|
692
692
|
def path
|
693
|
-
|
693
|
+
old_enum_value.path
|
694
694
|
end
|
695
695
|
end
|
696
696
|
|
@@ -706,16 +706,15 @@ module GraphQL
|
|
706
706
|
|
707
707
|
def message
|
708
708
|
if old_enum_value.deprecation_reason
|
709
|
-
"Enum value `#{
|
709
|
+
"Enum value `#{new_enum_value.path}` deprecation reason changed " \
|
710
710
|
"from `#{old_enum_value.deprecation_reason}` to `#{new_enum_value.deprecation_reason}`"
|
711
711
|
else
|
712
|
-
"Enum value `#{
|
713
|
-
" `#{new_enum_value.deprecation_reason}`"
|
712
|
+
"Enum value `#{new_enum_value.path}` was deprecated with reason `#{new_enum_value.deprecation_reason}`"
|
714
713
|
end
|
715
714
|
end
|
716
715
|
|
717
716
|
def path
|
718
|
-
|
717
|
+
old_enum_value.path
|
719
718
|
end
|
720
719
|
end
|
721
720
|
|
@@ -730,12 +729,12 @@ module GraphQL
|
|
730
729
|
end
|
731
730
|
|
732
731
|
def message
|
733
|
-
"Input field `#{
|
732
|
+
"Input field `#{old_field.path}` description changed"\
|
734
733
|
" from `#{old_field.description}` to `#{new_field.description}`"
|
735
734
|
end
|
736
735
|
|
737
736
|
def path
|
738
|
-
|
737
|
+
old_field.path
|
739
738
|
end
|
740
739
|
end
|
741
740
|
|
@@ -769,12 +768,12 @@ module GraphQL
|
|
769
768
|
end
|
770
769
|
|
771
770
|
def message
|
772
|
-
"Field `#{
|
771
|
+
"Field `#{old_field.path}` description changed"\
|
773
772
|
" from `#{old_field.description}` to `#{new_field.description}`"
|
774
773
|
end
|
775
774
|
|
776
775
|
def path
|
777
|
-
|
776
|
+
old_field.path
|
778
777
|
end
|
779
778
|
end
|
780
779
|
|
@@ -790,12 +789,12 @@ module GraphQL
|
|
790
789
|
end
|
791
790
|
|
792
791
|
def message
|
793
|
-
"Description for argument `#{new_argument.graphql_name}` on field `#{
|
792
|
+
"Description for argument `#{new_argument.graphql_name}` on field `#{field.path}` changed"\
|
794
793
|
" from `#{old_argument.description}` to `#{new_argument.description}`"
|
795
794
|
end
|
796
795
|
|
797
796
|
def path
|
798
|
-
|
797
|
+
old_argument.path
|
799
798
|
end
|
800
799
|
end
|
801
800
|
|
@@ -830,12 +829,12 @@ module GraphQL
|
|
830
829
|
end
|
831
830
|
|
832
831
|
def message
|
833
|
-
"Deprecation reason on field `#{
|
832
|
+
"Deprecation reason on field `#{new_field.path}` has changed "\
|
834
833
|
"from `#{old_field.deprecation_reason}` to `#{new_field.deprecation_reason}`"
|
835
834
|
end
|
836
835
|
|
837
836
|
def path
|
838
|
-
|
837
|
+
old_field.path
|
839
838
|
end
|
840
839
|
end
|
841
840
|
|
@@ -849,11 +848,11 @@ module GraphQL
|
|
849
848
|
end
|
850
849
|
|
851
850
|
def message
|
852
|
-
"Field `#{field.graphql_name}` was added to object type `#{object_type.
|
851
|
+
"Field `#{field.graphql_name}` was added to object type `#{object_type.graphql_name}`"
|
853
852
|
end
|
854
853
|
|
855
854
|
def path
|
856
|
-
[object_type.
|
855
|
+
[object_type.graphql_name, field.graphql_name].join(".")
|
857
856
|
end
|
858
857
|
end
|
859
858
|
|
@@ -21,7 +21,7 @@ module GraphQL
|
|
21
21
|
changes << Changes::FieldArgumentDefaultChanged.new(type, field, old_arg, new_arg)
|
22
22
|
end
|
23
23
|
|
24
|
-
if old_arg.type.
|
24
|
+
if old_arg.type.to_type_signature != new_arg.type.to_type_signature
|
25
25
|
changes << Changes::FieldArgumentTypeChanged.new(type, field, old_arg, new_arg)
|
26
26
|
end
|
27
27
|
|
@@ -39,11 +39,11 @@ module GraphQL
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def removed_arguments
|
42
|
-
old_arguments.values.select { |arg| !new_arguments[arg.
|
42
|
+
old_arguments.values.select { |arg| !new_arguments[arg.graphql_name] }
|
43
43
|
end
|
44
44
|
|
45
45
|
def added_arguments
|
46
|
-
new_arguments.values.select { |arg| !old_arguments[arg.
|
46
|
+
new_arguments.values.select { |arg| !old_arguments[arg.graphql_name] }
|
47
47
|
end
|
48
48
|
|
49
49
|
def each_common_argument(&block)
|
@@ -19,7 +19,7 @@ module GraphQL
|
|
19
19
|
changes << Changes::DirectiveArgumentDefaultChanged.new(directive, old_arg, new_arg)
|
20
20
|
end
|
21
21
|
|
22
|
-
if old_arg.type
|
22
|
+
if old_arg.type != new_arg.type
|
23
23
|
changes << Changes::DirectiveArgumentTypeChanged.new(directive, old_arg, new_arg)
|
24
24
|
end
|
25
25
|
|
@@ -24,7 +24,7 @@ module GraphQL
|
|
24
24
|
changes << Changes::FieldDeprecationChanged.new(new_type, old_field, new_field)
|
25
25
|
end
|
26
26
|
|
27
|
-
if old_field.type.
|
27
|
+
if old_field.type.to_type_signature != new_field.type.to_type_signature
|
28
28
|
changes << Changes::FieldTypeChanged.new(new_type, old_field, new_field)
|
29
29
|
end
|
30
30
|
|
@@ -51,12 +51,12 @@ module GraphQL
|
|
51
51
|
)
|
52
52
|
|
53
53
|
def arg_removals
|
54
|
-
removed = old_arguments.values.select { |arg| !new_arguments[arg.
|
54
|
+
removed = old_arguments.values.select { |arg| !new_arguments[arg.graphql_name] }
|
55
55
|
removed.map { |arg| Changes::FieldArgumentRemoved.new(new_type, old_field, arg) }
|
56
56
|
end
|
57
57
|
|
58
58
|
def arg_additions
|
59
|
-
removed = new_arguments.values.select { |arg| !old_arguments[arg.
|
59
|
+
removed = new_arguments.values.select { |arg| !old_arguments[arg.graphql_name] }
|
60
60
|
removed.map { |arg| Changes::FieldArgumentAdded.new(new_type, new_field, arg) }
|
61
61
|
end
|
62
62
|
|
@@ -21,7 +21,7 @@ module GraphQL
|
|
21
21
|
changes << Changes::InputFieldDefaultChanged.new(old_type, old_field, new_field)
|
22
22
|
end
|
23
23
|
|
24
|
-
if old_field.type.
|
24
|
+
if old_field.type.to_type_signature != new_field.type.to_type_signature
|
25
25
|
changes << Changes::InputFieldTypeChanged.new(old_type, old_field, new_field)
|
26
26
|
end
|
27
27
|
|
@@ -39,11 +39,11 @@ module GraphQL
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def removed_fields
|
42
|
-
old_fields.values.select { |field| !new_fields[field.
|
42
|
+
old_fields.values.select { |field| !new_fields[field.graphql_name] }
|
43
43
|
end
|
44
44
|
|
45
45
|
def added_fields
|
46
|
-
new_fields.values.select { |field| !old_fields[field.
|
46
|
+
new_fields.values.select { |field| !old_fields[field.graphql_name] }
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -2,12 +2,12 @@ module GraphQL
|
|
2
2
|
module SchemaComparator
|
3
3
|
module Diff
|
4
4
|
class Interface
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@
|
5
|
+
def initialize(old_interface, new_interface)
|
6
|
+
@old_interface = old_interface
|
7
|
+
@new_interface = new_interface
|
8
8
|
|
9
|
-
@old_fields =
|
10
|
-
@new_fields =
|
9
|
+
@old_fields = old_interface.fields
|
10
|
+
@new_fields = new_interface.fields
|
11
11
|
end
|
12
12
|
|
13
13
|
def diff
|
@@ -16,7 +16,7 @@ module GraphQL
|
|
16
16
|
changes += field_additions
|
17
17
|
|
18
18
|
each_common_field do |old_field, new_field|
|
19
|
-
changes += Diff::Field.new(
|
19
|
+
changes += Diff::Field.new(old_interface, new_interface, old_field, new_field).diff
|
20
20
|
end
|
21
21
|
|
22
22
|
changes
|
@@ -24,23 +24,23 @@ module GraphQL
|
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
-
attr_reader :
|
27
|
+
attr_reader :old_interface, :new_interface, :old_fields, :new_fields
|
28
28
|
|
29
29
|
def field_removals
|
30
|
-
removed = old_fields.values.select { |field| !new_fields[field.
|
31
|
-
removed.map { |field| Changes::FieldRemoved.new(
|
30
|
+
removed = old_fields.values.select { |field| !new_fields[field.graphql_name] }
|
31
|
+
removed.map { |field| Changes::FieldRemoved.new(old_interface, field) }
|
32
32
|
end
|
33
33
|
|
34
34
|
def field_additions
|
35
|
-
added = new_fields.values.select { |field| !old_fields[field.
|
36
|
-
added.map { |field| Changes::FieldAdded.new(
|
35
|
+
added = new_fields.values.select { |field| !old_fields[field.graphql_name] }
|
36
|
+
added.map { |field| Changes::FieldAdded.new(new_interface, field) }
|
37
37
|
end
|
38
38
|
|
39
39
|
def each_common_field(&block)
|
40
40
|
intersection = old_fields.keys & new_fields.keys
|
41
41
|
intersection.each do |common_field|
|
42
|
-
old_field =
|
43
|
-
new_field =
|
42
|
+
old_field = old_interface.fields[common_field]
|
43
|
+
new_field = new_interface.fields[common_field]
|
44
44
|
|
45
45
|
block.call(old_field, new_field)
|
46
46
|
end
|
@@ -3,8 +3,8 @@ module GraphQL
|
|
3
3
|
module Diff
|
4
4
|
class ObjectType
|
5
5
|
def initialize(old_type, new_type)
|
6
|
-
@old_type = old_type
|
7
|
-
@new_type = new_type
|
6
|
+
@old_type = old_type
|
7
|
+
@new_type = new_type
|
8
8
|
|
9
9
|
@old_fields = old_type.fields
|
10
10
|
@new_fields = new_type.fields
|
@@ -41,25 +41,25 @@ module GraphQL
|
|
41
41
|
|
42
42
|
def interface_removals
|
43
43
|
removed = filter_interfaces(old_interfaces, new_interfaces)
|
44
|
-
removed.map { |
|
44
|
+
removed.map { |interface| Changes::ObjectTypeInterfaceRemoved.new(interface, old_type) }
|
45
45
|
end
|
46
46
|
|
47
47
|
def interface_additions
|
48
48
|
added = filter_interfaces(new_interfaces, old_interfaces)
|
49
|
-
added.map { |
|
49
|
+
added.map { |interface| Changes::ObjectTypeInterfaceAdded.new(interface, new_type) }
|
50
50
|
end
|
51
51
|
|
52
52
|
def filter_interfaces(interfaces, excluded_interfaces)
|
53
|
-
interfaces.select { |interface| !excluded_interfaces.map(&:
|
53
|
+
interfaces.select { |interface| !excluded_interfaces.map(&:graphql_name).include?(interface.graphql_name) }
|
54
54
|
end
|
55
55
|
|
56
56
|
def field_removals
|
57
|
-
removed = old_fields.values.select { |field| !new_fields[field.
|
57
|
+
removed = old_fields.values.select { |field| !new_fields[field.graphql_name] }
|
58
58
|
removed.map { |field| Changes::FieldRemoved.new(old_type, field) }
|
59
59
|
end
|
60
60
|
|
61
61
|
def field_additions
|
62
|
-
added = new_fields.values.select { |field| !old_fields[field.
|
62
|
+
added = new_fields.values.select { |field| !old_fields[field.graphql_name] }
|
63
63
|
added.map { |field| Changes::FieldAdded.new(new_type, field) }
|
64
64
|
end
|
65
65
|
|
@@ -40,16 +40,16 @@ module GraphQL
|
|
40
40
|
if old_type.kind != new_type.kind
|
41
41
|
changes << Changes::TypeKindChanged.new(old_type, new_type)
|
42
42
|
else
|
43
|
-
case old_type.
|
44
|
-
when
|
43
|
+
case old_type.kind.name
|
44
|
+
when "ENUM"
|
45
45
|
changes += Diff::Enum.new(old_type, new_type).diff
|
46
|
-
when
|
46
|
+
when "UNION"
|
47
47
|
changes += Diff::Union.new(old_type, new_type).diff
|
48
|
-
when
|
48
|
+
when "INPUT_OBJECT"
|
49
49
|
changes += Diff::InputObject.new(old_type, new_type).diff
|
50
|
-
when
|
50
|
+
when "OBJECT"
|
51
51
|
changes += Diff::ObjectType.new(old_type, new_type).diff
|
52
|
-
when
|
52
|
+
when "INTERFACE"
|
53
53
|
changes += Diff::Interface.new(old_type, new_type).diff
|
54
54
|
end
|
55
55
|
end
|
@@ -64,15 +64,15 @@ module GraphQL
|
|
64
64
|
def changes_in_schema
|
65
65
|
changes = []
|
66
66
|
|
67
|
-
if old_schema.query&.
|
67
|
+
if old_schema.query&.graphql_name != new_schema.query&.graphql_name
|
68
68
|
changes << Changes::SchemaQueryTypeChanged.new(old_schema, new_schema)
|
69
69
|
end
|
70
70
|
|
71
|
-
if old_schema.mutation&.
|
71
|
+
if old_schema.mutation&.graphql_name != new_schema.mutation&.graphql_name
|
72
72
|
changes << Changes::SchemaMutationTypeChanged.new(old_schema, new_schema)
|
73
73
|
end
|
74
74
|
|
75
|
-
if old_schema.subscription&.
|
75
|
+
if old_schema.subscription&.graphql_name != new_schema.subscription&.graphql_name
|
76
76
|
changes << Changes::SchemaSubscriptionTypeChanged.new(old_schema, new_schema)
|
77
77
|
end
|
78
78
|
|
@@ -34,7 +34,7 @@ module GraphQL
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def filter_types(types, exclude_types)
|
37
|
-
types.select { |type| !exclude_types.map(&:
|
37
|
+
types.select { |type| !exclude_types.map(&:graphql_name).include?(type.graphql_name) }
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-schema_comparator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc-Andre Giroux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.10'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.10'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: thor
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,7 +106,7 @@ dependencies:
|
|
100
106
|
- - "~>"
|
101
107
|
- !ruby/object:Gem::Version
|
102
108
|
version: '3.4'
|
103
|
-
description: GraphQL::SchemaComparator compares two GraphQL schemas given their
|
109
|
+
description: GraphQL::SchemaComparator compares two GraphQL schemas given their SDL
|
104
110
|
and returns a list of changes.
|
105
111
|
email:
|
106
112
|
- mgiroux0@gmail.com
|
@@ -122,6 +128,9 @@ files:
|
|
122
128
|
- bin/graphql-schema
|
123
129
|
- bin/schema_comparator
|
124
130
|
- bin/setup
|
131
|
+
- gemfiles/graphql-head.gemfile
|
132
|
+
- gemfiles/graphql1.10.gemfile
|
133
|
+
- gemfiles/graphql1.13.gemfile
|
125
134
|
- graphql-schema_comparator.gemspec
|
126
135
|
- lib/graphql/schema_comparator.rb
|
127
136
|
- lib/graphql/schema_comparator/changes.rb
|
@@ -132,7 +141,6 @@ files:
|
|
132
141
|
- lib/graphql/schema_comparator/diff/directive_argument.rb
|
133
142
|
- lib/graphql/schema_comparator/diff/enum.rb
|
134
143
|
- lib/graphql/schema_comparator/diff/field.rb
|
135
|
-
- lib/graphql/schema_comparator/diff/has_directives.rb
|
136
144
|
- lib/graphql/schema_comparator/diff/input_field.rb
|
137
145
|
- lib/graphql/schema_comparator/diff/input_object.rb
|
138
146
|
- lib/graphql/schema_comparator/diff/interface.rb
|
@@ -142,10 +150,14 @@ files:
|
|
142
150
|
- lib/graphql/schema_comparator/result.rb
|
143
151
|
- lib/graphql/schema_comparator/version.rb
|
144
152
|
- schema.graphql
|
145
|
-
homepage:
|
153
|
+
homepage: https://github.com/xuorig/graphql-schema_comparator
|
146
154
|
licenses:
|
147
155
|
- MIT
|
148
|
-
metadata:
|
156
|
+
metadata:
|
157
|
+
homepage_uri: https://github.com/xuorig/graphql-schema_comparator
|
158
|
+
changelog_uri: https://github.com/xuorig/graphql-schema_comparator/blob/master/CHANGELOG.md
|
159
|
+
source_code_uri: https://github.com/xuorig/graphql-schema_comparator
|
160
|
+
bug_tracker_uri: https://github.com/xuorig/graphql-schema_comparator/issues
|
149
161
|
post_install_message:
|
150
162
|
rdoc_options: []
|
151
163
|
require_paths:
|
@@ -161,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
173
|
- !ruby/object:Gem::Version
|
162
174
|
version: '0'
|
163
175
|
requirements: []
|
164
|
-
rubygems_version: 3.0.3
|
176
|
+
rubygems_version: 3.0.3.1
|
165
177
|
signing_key:
|
166
178
|
specification_version: 4
|
167
179
|
summary: Compare GraphQL schemas and get the changes that happened.
|
File without changes
|