graphql-schema_comparator 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ae1770b6fad8e77502e03cb613fbc5bf5546bc96d535e2af0f622c2794102c0
4
- data.tar.gz: 5edcad6f5ce2fea8a2e83c79279e4bee868d5e3507af254176931341d7d46506
3
+ metadata.gz: fbc98aaf530ce8c60dc291eac091f735180bedd7962f4229d6fc9ad19fcf02a9
4
+ data.tar.gz: e80de95b6b466297e8c69679cd2f4590f7bc77072573df004b0c8e266e06a9ef
5
5
  SHA512:
6
- metadata.gz: e10aae6486a79da4eb4e9fb6e3787ac166d5d54848bf2eea37b8885839c83efe8de97af8dc84fa732d7c1582567050b0469fba5d546a85b9183b6ccdcb4582a2
7
- data.tar.gz: 1a879654fecfb43824872cf9c4907d4edaa221645d6d91a062b7f933cb0cf0ce43587e6d840451f7027b9da8aed99c45fd8d0af84bc3403901c6a93eb2764cb4
6
+ metadata.gz: 22b0ef77facfe02f84f0d14004c4576d415d9b3c4b3fe46d06ed0a3750ea302180217c1aec1b54cdefd0517f66a0f89a61789643ad66031766205cc03e95459f
7
+ data.tar.gz: 4e2251295877a04cfa6e15654470db736a52bda927be70dc0d3846e358d6d6d7d11553a04bfff383eb460d62b466bcb7610d3bb84d16fb613418af8d7884df4c
@@ -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
- [![Build Status](https://travis-ci.org/xuorig/graphql-schema_comparator.svg?branch=master)](https://travis-ci.org/xuorig/graphql-schema_comparator)
3
+ ![Build status](https://github.com/xuorig/graphql-schema_comparator/actions/workflows/ci.yml/badge.svg)
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:
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "graphql", "~> 1.13", "< 3.0"
4
+
5
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "graphql", "~> 1.10.0"
4
+
5
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "graphql", "~> 1.13.0"
4
+
5
+ gemspec path: "../"
@@ -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 IDL and returns a list of changes.}
14
- spec.homepage = "http://mgiroux.me"
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", "~> 1.10"
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
 
@@ -14,7 +14,7 @@ module GraphQL
14
14
  # these changes.
15
15
  DANGEROUS = 2
16
16
 
17
- # Breaking criticality are changes that immediatly impact
17
+ # Breaking criticality are changes that immediately impact
18
18
  # clients usually causing queries not to be valid anymore.
19
19
  BREAKING = 3
20
20
 
@@ -51,11 +51,11 @@ module GraphQL
51
51
  end
52
52
 
53
53
  def message
54
- "Type `#{removed_type.graphql_definition}` was removed"
54
+ "Type `#{removed_type.graphql_name}` was removed"
55
55
  end
56
56
 
57
57
  def path
58
- removed_type.graphql_definition.to_s
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.graphql_definition}` kind changed from `#{old_type.kind}` to `#{new_type.kind}`"
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.graphql_definition.to_s
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.graphql_definition}`"
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
- [enum_type.graphql_definition, enum_value.graphql_name].join('.')
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.graphql_definition}`"
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.graphql_definition.to_s
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.graphql_definition}`"
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
- [input_object_type.graphql_definition, field.graphql_name].join('.')
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.graphql_definition}` was removed from field `#{object_type.graphql_definition}.#{field.graphql_name}`"
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
- [object_type.graphql_definition, field.graphql_name, argument.graphql_name].join('.')
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.graphql_definition}`"
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.graphql_definition, field.graphql_name].join('.')
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.graphql_definition}` object type no longer implements `#{interface.graphql_name}` interface"
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.graphql_definition.to_s
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 `#{type.graphql_definition}.#{old_field.graphql_name}` changed type from `#{old_field.type.graphql_definition}` to `#{new_field.type.graphql_definition}`"
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
- [type.graphql_definition, old_field.graphql_name].join('.')
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 `#{input_type.graphql_definition}.#{old_input_field.graphql_name}` changed type from `#{old_input_field.type.graphql_definition}` to `#{new_input_field.type.graphql_definition}`"
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
- [input_type.graphql_definition, old_input_field.graphql_name].join('.')
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 `#{type.graphql_definition}.#{field.graphql_definition.name}` changed"\
364
- " from `#{old_argument.type.graphql_definition}` to `#{new_argument.type.graphql_definition}`"
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
- [type.graphql_definition, field.graphql_definition.name, old_argument.graphql_name].join('.')
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.graphql_definition}` to `#{new_argument.type.graphql_definition}`"
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 `#{type.graphql_definition}.#{field.graphql_name}`"
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 `#{type.graphql_definition}.#{field.name}` changed"\
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
- [type.graphql_definition, field.graphql_name, old_argument.graphql_name].join('.')
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 `#{input_type.graphql_definition}.#{old_field.graphql_name}` default changed"\
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
- [input_type.graphql_definition, old_field.graphql_name].join(".")
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.graphql_definition}`"
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
- [enum_type.graphql_definition, enum_value.graphql_name].join(".")
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.graphql_definition}`"
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.graphql_definition.to_s
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.graphql_definition}` object implements `#{interface.graphql_name}` interface"
568
+ "`#{object_type.graphql_name}` object implements `#{interface.graphql_name}` interface"
569
569
  end
570
570
 
571
571
  def path
572
- object_type.graphql_definition.to_s
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.graphql_definition}`"
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
- [input_object_type.graphql_definition, field.graphql_name].join(".")
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.graphql_definition}` added to field `#{type.graphql_definition}.#{field.graphql_name}`"
617
+ "Argument `#{argument.graphql_name}: #{argument.type.graphql_name}` added to field `#{field.path}`"
618
618
  end
619
619
 
620
620
  def path
621
- [type.graphql_definition, field.graphql_name, argument.graphql_name].join(".")
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.graphql_definition}` was added"
634
+ "Type `#{type.graphql_name}` was added"
635
635
  end
636
636
 
637
637
  def path
638
- type.graphql_definition.to_s
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.graphql_definition}` has changed to `#{new_type.description}`"
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.graphql_definition.to_s
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 `#{enum.graphql_name}.#{new_enum_value.graphql_name}` changed from " \
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
- [enum.graphql_name, old_enum_value.graphql_name].join(".")
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 `#{enum.graphql_name}.#{new_enum_value.graphql_name}` deprecation reason changed " \
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 `#{enum.graphql_name}.#{new_enum_value.graphql_name}` was deprecated with reason" \
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
- [enum.graphql_name, old_enum_value.graphql_name].join(".")
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 `#{input_type.graphql_definition}.#{old_field.graphql_name}` description changed"\
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
- [input_type.graphql_definition, old_field.graphql_name].join(".")
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 `#{type.graphql_definition}.#{old_field.graphql_name}` description changed"\
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
- [type.graphql_definition, old_field.graphql_name].join(".")
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 `#{type.graphql_definition}.#{field.graphql_name}` changed"\
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
- [type.graphql_definition, field.graphql_name, old_argument.graphql_name].join(".")
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 `#{type.graphql_definition}.#{new_field.graphql_name}` has changed "\
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
- [type.graphql_definition, old_field.graphql_name].join(".")
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.graphql_definition}`"
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.graphql_definition, field.graphql_name].join(".")
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.graphql_definition != new_arg.type.graphql_definition
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.name] }
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.name] }
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.graphql_definition != new_arg.type.graphql_definition
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.graphql_definition != new_field.type.graphql_definition
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.name] }
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.name] }
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.graphql_definition != new_field.type.graphql_definition
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.name] }
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.name] }
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(old_iface, new_iface)
6
- @old_iface = old_iface
7
- @new_iface = new_iface
5
+ def initialize(old_interface, new_interface)
6
+ @old_interface = old_interface
7
+ @new_interface = new_interface
8
8
 
9
- @old_fields = old_iface.fields
10
- @new_fields = new_iface.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(old_iface, new_iface, old_field, new_field).diff
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 :old_iface, :new_iface, :old_fields, :new_fields
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.name] }
31
- removed.map { |field| Changes::FieldRemoved.new(old_iface, field) }
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.name] }
36
- added.map { |field| Changes::FieldAdded.new(new_iface, field) }
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 = old_iface.fields[common_field]
43
- new_field = new_iface.fields[common_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.graphql_definition
7
- @new_type = new_type.graphql_definition
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 { |iface| Changes::ObjectTypeInterfaceRemoved.new(iface, old_type) }
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 { |iface| Changes::ObjectTypeInterfaceAdded.new(iface, new_type) }
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(&:graphql_definition).include?(interface.graphql_definition) }
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.name] }
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.name] }
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.graphql_definition
44
- when GraphQL::EnumType
43
+ case old_type.kind.name
44
+ when "ENUM"
45
45
  changes += Diff::Enum.new(old_type, new_type).diff
46
- when GraphQL::UnionType
46
+ when "UNION"
47
47
  changes += Diff::Union.new(old_type, new_type).diff
48
- when GraphQL::InputObjectType
48
+ when "INPUT_OBJECT"
49
49
  changes += Diff::InputObject.new(old_type, new_type).diff
50
- when GraphQL::ObjectType
50
+ when "OBJECT"
51
51
  changes += Diff::ObjectType.new(old_type, new_type).diff
52
- when GraphQL::InterfaceType
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&.to_graphql != new_schema.query&.to_graphql
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&.to_graphql != new_schema.mutation&.to_graphql
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&.to_graphql != new_schema.subscription&.to_graphql
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(&:graphql_definition).include?(type.graphql_definition) }
37
+ types.select { |type| !exclude_types.map(&:graphql_name).include?(type.graphql_name) }
38
38
  end
39
39
  end
40
40
  end
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module SchemaComparator
3
- VERSION = "1.0.1"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  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.1
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-05-26 00:00:00.000000000 Z
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 IDL
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: http://mgiroux.me
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