graphql-schema_comparator 0.6.1 → 1.1.1

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
- SHA1:
3
- metadata.gz: fb19e37d9e3d7037094e788cce01bd91fe88fbe6
4
- data.tar.gz: dd33278458a8405503abf0c34b8fbd6fb565a5c5
2
+ SHA256:
3
+ metadata.gz: 0ec082ccd9621ae89f5a9ed29c027cbff4a785a3bac913bd5000b3e1a914f43d
4
+ data.tar.gz: f6924765894399193664e370a2464327c20e1ed0c9f35d252699893c75706736
5
5
  SHA512:
6
- metadata.gz: 5a6592586307a89a97e5d62dcf623310a8d09c4dd9c4c5a496f9556649cbb56ecdc3c4a2de97494e27b5c04d9e97a816e8e02a20e52a532f7fc672165f13af69
7
- data.tar.gz: a4c7eaf05826ce093c6772a7a3aa024e73d44b2df7dad968e4ae161188fbbe9dfaec608a6e78e242ebc350ddb55be5d271412d0548aa64dcae65a4072f764fcb
6
+ metadata.gz: 326440a4c85adbadc3c0fafb262653e88226a55cec0a1d336a750270925a334bdfbcbfeec62e36dfa5f08d4179e8a2304622fc0e34520695de1c67ee20833a0c
7
+ data.tar.gz: '069cf716049a9746cb88825734d968112ed512312c12d69da39a6d019f1257d9c74357cae5d7756bdfc5c9f8bea2f2ab8ec0bfbe21664b2e7e1e7c24d046b37e'
@@ -0,0 +1,23 @@
1
+ name: Tests
2
+
3
+ on:
4
+ - push
5
+ - pull_request
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
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
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ bundler-cache: true
22
+ ruby-version: ${{ matrix.ruby }}
23
+ - run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.1 (January 7 2022)
4
+
5
+ ### Bug Fix
6
+
7
+ - Fix directive type change false positive bug (#47)
8
+
9
+ ## 1.1.0 (December 20 2021)
10
+
11
+ ### Bug Fix
12
+
13
+ - Adding non-null arguments with a default value should be non-breaking (#38)
14
+
15
+ ### New Features
16
+
17
+ - Remove legacy `graphql` gem API usage and support versions >= 1.13 (#46)
18
+
19
+ ## 1.0.1 (May 26 2021)
20
+
21
+ ### Bug Fix
22
+
23
+ - Fix comparing directives (#36)
24
+
25
+ ## 1.0.0 (January 23 2020)
26
+
27
+ ### Breaking Changes
28
+
29
+ - Add support for graphql-ruby 1.10.0+ (#28)
30
+ - Starting from 1.0.0 a minimum of graphql-ruby 1.10 is required
31
+
3
32
  ## 0.6.1 (May 21rst 2019)
4
33
 
5
34
  - Added a bunch of reasons to breaking changes (#17)
@@ -54,32 +83,32 @@ Added changes:
54
83
 
55
84
  ### Bug fixes
56
85
 
57
- Fix issue in Enum differ (https://github.com/xuorig/graphql-schema_comparator/issues/9)
86
+ - Fix issue in Enum differ (https://github.com/xuorig/graphql-schema_comparator/issues/9)
58
87
 
59
88
  ## 0.3.1 (Nov 13 2017)
60
89
 
61
90
  ### Bug Fixes
62
91
 
63
- - Fix no method breaking issue https://github.com/xuorig/graphql-schema_comparator/issues/8
92
+ - Fix no method breaking issue https://github.com/xuorig/graphql-schema_comparator/issues/8
64
93
 
65
94
  ## 0.3.0 (Oct 14 2017)
66
95
 
67
96
  ### New features
68
97
 
69
- - Top level Directive definitions are now diffed, but not directives used on definitions (Coming soon)
70
- - Base class for changes added.
98
+ - Top level Directive definitions are now diffed, but not directives used on definitions (Coming soon)
99
+ - Base class for changes added.
71
100
 
72
101
  ### breaking changes
73
102
 
74
- - `breaking` method on change objects has been renamed `breaking?` for style
103
+ - `breaking` method on change objects has been renamed `breaking?` for style
75
104
 
76
105
  ## 0.2.0 (Aug 18 2017)
77
106
 
78
107
  ### New features
79
108
 
80
- - Add `#non_breaking_changes` to get a list of non breaking changes from a comparison result. (#4)
81
- - CLI now Prints results sorted and grouped by breaking / non-breaking (#3)
109
+ - Add `#non_breaking_changes` to get a list of non breaking changes from a comparison result. (#4)
110
+ - CLI now Prints results sorted and grouped by breaking / non-breaking (#3)
82
111
 
83
112
  ### Bug fixes
84
113
 
85
- - Fix message for `EnumValueRemoved` (#5)
114
+ - Fix message for `EnumValueRemoved` (#5)
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 TODO: Write your name
3
+ Copyright (c) 2017 Marc-Andre Giroux
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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.6"
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.name}` was removed"
54
+ "Type `#{removed_type.graphql_name}` was removed"
55
55
  end
56
56
 
57
57
  def path
58
- removed_type.name
58
+ removed_type.path
59
59
  end
60
60
  end
61
61
 
@@ -68,11 +68,11 @@ module GraphQL
68
68
  end
69
69
 
70
70
  def message
71
- "Directive `#{directive.name}` was removed"
71
+ "Directive `#{directive.graphql_name}` was removed"
72
72
  end
73
73
 
74
74
  def path
75
- "@#{directive.name}"
75
+ "@#{directive.graphql_name}"
76
76
  end
77
77
  end
78
78
 
@@ -88,11 +88,11 @@ module GraphQL
88
88
  end
89
89
 
90
90
  def message
91
- "`#{old_type.name}` 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.name
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.name}` was removed from enum `#{enum_type.name}`"
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.name, enum_value.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.name}` was removed from Union type `#{union_type.name}`"
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.name
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.name}` was removed from input object type `#{input_object_type.name}`"
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.name, field.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.name}: #{argument.type}` was removed from field `#{object_type.name}.#{field.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.name, field.name, argument.name].join('.')
176
+ argument.path
177
177
  end
178
178
  end
179
179
 
@@ -187,11 +187,11 @@ module GraphQL
187
187
  end
188
188
 
189
189
  def message
190
- "Argument `#{argument.name}` was removed from directive `#{directive.name}`"
190
+ "Argument `#{argument.graphql_name}` was removed from directive `#{directive.graphql_name}`"
191
191
  end
192
192
 
193
193
  def path
194
- ["@#{directive.name}", argument.name].join('.')
194
+ ["@#{directive.graphql_name}", argument.graphql_name].join('.')
195
195
  end
196
196
  end
197
197
 
@@ -205,7 +205,7 @@ module GraphQL
205
205
  end
206
206
 
207
207
  def message
208
- "Schema query root has changed from `#{old_schema.query.name}` to `#{new_schema.query.name}`"
208
+ "Schema query root has changed from `#{old_schema.query.graphql_name}` to `#{new_schema.query.graphql_name}`"
209
209
  end
210
210
 
211
211
  def path
@@ -233,11 +233,11 @@ module GraphQL
233
233
  end
234
234
 
235
235
  def message
236
- "Field `#{field.name}` was removed from object type `#{object_type.name}`"
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.name, field.name].join('.')
240
+ [object_type.graphql_name, field.graphql_name].join(".")
241
241
  end
242
242
  end
243
243
 
@@ -251,11 +251,11 @@ module GraphQL
251
251
  end
252
252
 
253
253
  def message
254
- "Location `#{location}` was removed from directive `#{directive.name}`"
254
+ "Location `#{location}` was removed from directive `#{directive.graphql_name}`"
255
255
  end
256
256
 
257
257
  def path
258
- "@#{directive.name}"
258
+ "@#{directive.graphql_name}"
259
259
  end
260
260
  end
261
261
 
@@ -271,11 +271,11 @@ module GraphQL
271
271
  end
272
272
 
273
273
  def message
274
- "`#{object_type.name}` object type no longer implements `#{interface.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.name
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}.#{old_field.name}` changed type from `#{old_field.type}` to `#{new_field.type}`"
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.name, old_field.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}.#{old_input_field.name}` changed type from `#{old_input_field.type}` to `#{new_input_field.type}`"
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.name, old_input_field.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.name}` on field `#{type.name}.#{field.name}` changed"\
364
- " from `#{old_argument.type}` to `#{new_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
- [type.name, field.name, old_argument.name].join('.')
368
+ old_argument.path
369
369
  end
370
370
  end
371
371
 
@@ -389,12 +389,12 @@ module GraphQL
389
389
  end
390
390
 
391
391
  def message
392
- "Type for argument `#{new_argument.name}` on directive `#{directive.name}` changed"\
393
- " from `#{old_argument.type}` to `#{new_argument.type}`"
392
+ "Type for argument `#{new_argument.graphql_name}` on directive `#{directive.graphql_name}` changed"\
393
+ " from `#{old_argument.type.to_type_signature}` to `#{new_argument.type.to_type_signature}`"
394
394
  end
395
395
 
396
396
  def path
397
- ["@#{directive.name}", old_argument.name].join('.')
397
+ ["@#{directive.graphql_name}", old_argument.graphql_name].join('.')
398
398
  end
399
399
  end
400
400
 
@@ -451,16 +451,16 @@ module GraphQL
451
451
  end
452
452
 
453
453
  def message
454
- if old_argument.default_value.nil?
455
- "Default value `#{new_argument.default_value}` was added to argument `#{new_argument.name}` on field `#{type.name}.#{field.name}`"
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 `#{field.path}`"
456
456
  else
457
- "Default value for argument `#{new_argument.name}` on field `#{type.name}.#{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.name, field.name, old_argument.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.name}.#{old_field.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.name, old_field.name].join(".")
486
+ old_field.path
487
487
  end
488
488
  end
489
489
 
@@ -501,12 +501,12 @@ module GraphQL
501
501
  end
502
502
 
503
503
  def message
504
- "Default value for argument `#{new_argument.name}` on directive `#{directive.name}` changed"\
504
+ "Default value for argument `#{new_argument.graphql_name}` on directive `#{directive.graphql_name}` changed"\
505
505
  " from `#{old_argument.default_value}` to `#{new_argument.default_value}`"
506
506
  end
507
507
 
508
508
  def path
509
- ["@#{directive.name}", new_argument.name].join(".")
509
+ ["@#{directive.graphql_name}", new_argument.graphql_name].join(".")
510
510
  end
511
511
  end
512
512
 
@@ -523,11 +523,11 @@ module GraphQL
523
523
  end
524
524
 
525
525
  def message
526
- "Enum value `#{enum_value.name}` was added to enum `#{enum_type.name}`"
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.name, enum_value.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.name}` was added to Union type `#{union_type.name}`"
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.name
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.name}` object implements `#{interface.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.name
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.name}` was added to input object type `#{input_object_type.name}`"
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.name, field.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.name}: #{argument.type}` added to field `#{type.name}.#{field.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.name, field.name, argument.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.name}` was added"
634
+ "Type `#{type.graphql_name}` was added"
635
635
  end
636
636
 
637
637
  def path
638
- type.name
638
+ type.path
639
639
  end
640
640
  end
641
641
 
@@ -648,11 +648,11 @@ module GraphQL
648
648
  end
649
649
 
650
650
  def message
651
- "Directive `#{directive.name}` was added"
651
+ "Directive `#{directive.graphql_name}` was added"
652
652
  end
653
653
 
654
654
  def path
655
- "@#{directive.name}"
655
+ "@#{directive.graphql_name}"
656
656
  end
657
657
  end
658
658
 
@@ -666,11 +666,11 @@ module GraphQL
666
666
  end
667
667
 
668
668
  def message
669
- "Description `#{old_type.description}` on type `#{old_type.name}` 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.name
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.name}.#{new_enum_value.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.name, old_enum_value.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.name}.#{new_enum_value.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.name}.#{new_enum_value.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.name, old_enum_value.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.name}.#{old_field.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.name, old_field.name].join(".")
737
+ old_field.path
739
738
  end
740
739
  end
741
740
 
@@ -749,12 +748,12 @@ module GraphQL
749
748
  end
750
749
 
751
750
  def message
752
- "Directive `#{new_directive.name}` description changed"\
751
+ "Directive `#{new_directive.graphql_name}` description changed"\
753
752
  " from `#{old_directive.description}` to `#{new_directive.description}`"
754
753
  end
755
754
 
756
755
  def path
757
- "@#{old_directive.name}"
756
+ "@#{old_directive.graphql_name}"
758
757
  end
759
758
  end
760
759
 
@@ -769,12 +768,12 @@ module GraphQL
769
768
  end
770
769
 
771
770
  def message
772
- "Field `#{type.name}.#{old_field.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.name, old_field.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.name}` on field `#{type.name}.#{field.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.name, field.name, old_argument.name].join(".")
797
+ old_argument.path
799
798
  end
800
799
  end
801
800
 
@@ -810,12 +809,12 @@ module GraphQL
810
809
  end
811
810
 
812
811
  def message
813
- "Description for argument `#{new_argument.name}` on directive `#{directive.name}` changed"\
812
+ "Description for argument `#{new_argument.graphql_name}` on directive `#{directive.graphql_name}` changed"\
814
813
  " from `#{old_argument.description}` to `#{new_argument.description}`"
815
814
  end
816
815
 
817
816
  def path
818
- ["@#{directive.name}", old_argument.name].join(".")
817
+ ["@#{directive.graphql_name}", old_argument.graphql_name].join(".")
819
818
  end
820
819
  end
821
820
 
@@ -830,12 +829,12 @@ module GraphQL
830
829
  end
831
830
 
832
831
  def message
833
- "Deprecation reason on field `#{type.name}.#{new_field.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.name, old_field.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.name}` was added to object type `#{object_type.name}`"
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.name, field.name].join(".")
855
+ [object_type.graphql_name, field.graphql_name].join(".")
857
856
  end
858
857
  end
859
858
 
@@ -867,11 +866,11 @@ module GraphQL
867
866
  end
868
867
 
869
868
  def message
870
- "Location `#{location}` was added to directive `#{directive.name}`"
869
+ "Location `#{location}` was added to directive `#{directive.graphql_name}`"
871
870
  end
872
871
 
873
872
  def path
874
- "@#{directive.name}"
873
+ "@#{directive.graphql_name}"
875
874
  end
876
875
  end
877
876
 
@@ -1033,7 +1032,7 @@ module GraphQL
1033
1032
  end
1034
1033
 
1035
1034
  def message
1036
- "Argument `#{argument.name}` was added to directive `#{directive.name}`"
1035
+ "Argument `#{argument.graphql_name}` was added to directive `#{directive.graphql_name}`"
1037
1036
  end
1038
1037
  end
1039
1038
  end
@@ -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 != new_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.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 != new_arg.type
22
+ if old_arg.type.to_type_signature != new_arg.type.to_type_signature
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 != new_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.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 != new_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.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
@@ -40,22 +40,26 @@ module GraphQL
40
40
  )
41
41
 
42
42
  def interface_removals
43
- removed = old_interfaces.select { |iface| !new_interfaces.include?(iface) }
44
- removed.map { |iface| Changes::ObjectTypeInterfaceRemoved.new(iface, old_type) }
43
+ removed = filter_interfaces(old_interfaces, new_interfaces)
44
+ removed.map { |interface| Changes::ObjectTypeInterfaceRemoved.new(interface, old_type) }
45
45
  end
46
46
 
47
47
  def interface_additions
48
- added = new_interfaces.select { |iface| !old_interfaces.include?(iface) }
49
- added.map { |iface| Changes::ObjectTypeInterfaceAdded.new(iface, new_type) }
48
+ added = filter_interfaces(new_interfaces, old_interfaces)
49
+ added.map { |interface| Changes::ObjectTypeInterfaceAdded.new(interface, new_type) }
50
+ end
51
+
52
+ def filter_interfaces(interfaces, excluded_interfaces)
53
+ interfaces.select { |interface| !excluded_interfaces.map(&:graphql_name).include?(interface.graphql_name) }
50
54
  end
51
55
 
52
56
  def field_removals
53
- removed = old_fields.values.select { |field| !new_fields[field.name] }
57
+ removed = old_fields.values.select { |field| !new_fields[field.graphql_name] }
54
58
  removed.map { |field| Changes::FieldRemoved.new(old_type, field) }
55
59
  end
56
60
 
57
61
  def field_additions
58
- added = new_fields.values.select { |field| !old_fields[field.name] }
62
+ added = new_fields.values.select { |field| !old_fields[field.graphql_name] }
59
63
  added.map { |field| Changes::FieldAdded.new(new_type, field) }
60
64
  end
61
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 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 != new_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 != new_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 != new_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
 
@@ -26,11 +26,15 @@ module GraphQL
26
26
  attr_reader :old_type, :new_type, :old_possible_types, :new_possible_types
27
27
 
28
28
  def removed_possible_types
29
- old_possible_types.select { |type| !new_possible_types.include?(type) }
29
+ filter_types(old_possible_types, new_possible_types)
30
30
  end
31
31
 
32
32
  def added_possible_types
33
- new_possible_types.select { |type| !old_possible_types.include?(type) }
33
+ filter_types(new_possible_types, old_possible_types)
34
+ end
35
+
36
+ def filter_types(types, exclude_types)
37
+ types.select { |type| !exclude_types.map(&:graphql_name).include?(type.graphql_name) }
34
38
  end
35
39
  end
36
40
  end
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module SchemaComparator
3
- VERSION = "0.6.1"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
@@ -35,7 +35,7 @@ module GraphQL
35
35
  private
36
36
 
37
37
  def self.parse_schema(schema)
38
- if schema.is_a?(GraphQL::Schema)
38
+ if schema.respond_to?(:ancestors) && schema.ancestors.include?(GraphQL::Schema)
39
39
  schema
40
40
  elsif schema.is_a?(String)
41
41
  GraphQL::Schema.from_definition(schema)
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: 0.6.1
4
+ version: 1.1.1
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: 2019-05-23 00:00:00.000000000 Z
11
+ date: 2022-01-07 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
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '1.6'
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
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.10'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '1.6'
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
@@ -110,8 +116,8 @@ executables:
110
116
  extensions: []
111
117
  extra_rdoc_files: []
112
118
  files:
119
+ - ".github/workflows/ci.yml"
113
120
  - ".gitignore"
114
- - ".travis.yml"
115
121
  - CHANGELOG.md
116
122
  - CODE_OF_CONDUCT.md
117
123
  - Gemfile
@@ -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,8 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
173
  - !ruby/object:Gem::Version
162
174
  version: '0'
163
175
  requirements: []
164
- rubyforge_project:
165
- rubygems_version: 2.6.8
176
+ rubygems_version: 3.0.3.1
166
177
  signing_key:
167
178
  specification_version: 4
168
179
  summary: Compare GraphQL schemas and get the changes that happened.
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- ---
2
- language: ruby
3
- sudo: false
4
- cache: bundler
5
- before_install:
6
- - gem update --system --no-doc
7
- - gem install bundler
8
- rvm:
9
- - 2.3.4
10
- - 2.4.1
File without changes