graphql-schema_comparator 0.6.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +23 -0
- data/CHANGELOG.md +37 -8
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/bin/schema_comparator +15 -2
- 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 +12 -7
- data/lib/graphql/schema_comparator/changes/criticality.rb +1 -1
- data/lib/graphql/schema_comparator/changes.rb +122 -95
- 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/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 +10 -6
- data/lib/graphql/schema_comparator/diff/schema.rb +9 -9
- data/lib/graphql/schema_comparator/diff/union.rb +6 -2
- data/lib/graphql/schema_comparator/version.rb +1 -1
- data/lib/graphql/schema_comparator.rb +1 -1
- metadata +35 -18
- data/.travis.yml +0 -10
- data/lib/graphql/schema_comparator/diff/has_directives.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
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
|
@@ -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.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
|
+
|
13
|
+
## 1.0.1 (May 26 2021)
|
14
|
+
|
15
|
+
### Bug Fix
|
16
|
+
|
17
|
+
- Fix comparing directives (#36)
|
18
|
+
|
19
|
+
## 1.0.0 (January 23 2020)
|
20
|
+
|
21
|
+
### Breaking Changes
|
22
|
+
|
23
|
+
- Add support for graphql-ruby 1.10.0+ (#28)
|
24
|
+
- Starting from 1.0.0 a minimum of graphql-ruby 1.10 is required
|
25
|
+
|
26
|
+
## 0.6.1 (May 21rst 2019)
|
27
|
+
|
28
|
+
- Added a bunch of reasons to breaking changes (#17)
|
29
|
+
- Relaxed Thor Dependency
|
30
|
+
- Add `verify` task for CI usage which returns exit codes depending on breaking changes (#24)
|
31
|
+
|
3
32
|
## 0.6.0 (Feb 28th 2018)
|
4
33
|
|
5
34
|
### New Features
|
@@ -48,32 +77,32 @@ Added changes:
|
|
48
77
|
|
49
78
|
### Bug fixes
|
50
79
|
|
51
|
-
Fix issue in Enum differ (https://github.com/xuorig/graphql-schema_comparator/issues/9)
|
80
|
+
- Fix issue in Enum differ (https://github.com/xuorig/graphql-schema_comparator/issues/9)
|
52
81
|
|
53
82
|
## 0.3.1 (Nov 13 2017)
|
54
83
|
|
55
84
|
### Bug Fixes
|
56
85
|
|
57
|
-
- Fix no method breaking issue https://github.com/xuorig/graphql-schema_comparator/issues/8
|
86
|
+
- Fix no method breaking issue https://github.com/xuorig/graphql-schema_comparator/issues/8
|
58
87
|
|
59
88
|
## 0.3.0 (Oct 14 2017)
|
60
89
|
|
61
90
|
### New features
|
62
91
|
|
63
|
-
- Top level Directive definitions are now diffed, but not directives used on definitions (Coming soon)
|
64
|
-
- Base class for changes added.
|
92
|
+
- Top level Directive definitions are now diffed, but not directives used on definitions (Coming soon)
|
93
|
+
- Base class for changes added.
|
65
94
|
|
66
95
|
### breaking changes
|
67
96
|
|
68
|
-
- `breaking` method on change objects has been renamed `breaking?` for style
|
97
|
+
- `breaking` method on change objects has been renamed `breaking?` for style
|
69
98
|
|
70
99
|
## 0.2.0 (Aug 18 2017)
|
71
100
|
|
72
101
|
### New features
|
73
102
|
|
74
|
-
- Add `#non_breaking_changes` to get a list of non breaking changes from a comparison result. (#4)
|
75
|
-
- CLI now Prints results sorted and grouped by breaking / non-breaking (#3)
|
103
|
+
- Add `#non_breaking_changes` to get a list of non breaking changes from a comparison result. (#4)
|
104
|
+
- CLI now Prints results sorted and grouped by breaking / non-breaking (#3)
|
76
105
|
|
77
106
|
### Bug fixes
|
78
107
|
|
79
|
-
- Fix message for `EnumValueRemoved` (#5)
|
108
|
+
- Fix message for `EnumValueRemoved` (#5)
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# GraphQL::SchemaComparator
|
2
2
|
|
3
|
-
|
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:
|
@@ -87,7 +87,7 @@ Possible changes are all found in [changes.rb](lib/graphql/schema_comparator/cha
|
|
87
87
|
|
88
88
|
### Change Criticality
|
89
89
|
|
90
|
-
Each change object has a
|
90
|
+
Each change object has a `#criticality` method which returns a `Changes::Criticality` object.
|
91
91
|
This objects defines how dangerous a change is to a schema.
|
92
92
|
|
93
93
|
The different levels of criticality (non_breaking, dangerous, breaking) are explained here:
|
data/bin/schema_comparator
CHANGED
@@ -5,9 +5,23 @@ require "thor"
|
|
5
5
|
require "graphql/schema_comparator"
|
6
6
|
|
7
7
|
class GraphQLSchema < Thor
|
8
|
+
desc "verify OLD_SCHEMA NEW_SCHEMA", "Behaves exactly like `compare` but returns an exit code for CI purposes"
|
9
|
+
|
10
|
+
def verify(old_schema, new_schema)
|
11
|
+
result = run_compare(old_schema, new_schema)
|
12
|
+
exit_code = result.breaking? ? 1 : 0
|
13
|
+
exit(exit_code)
|
14
|
+
end
|
15
|
+
|
8
16
|
desc "compare OLD_SCHEMA NEW_SCHEMA", "Compares OLD_SCHEMA with NEW_SCHEMA and returns a list of changes"
|
9
17
|
|
10
18
|
def compare(old_schema, new_schema)
|
19
|
+
run_compare(old_schema, new_schema)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def run_compare(old_schema, new_schema)
|
11
25
|
parsed_old = parse_schema(old_schema)
|
12
26
|
parsed_new = parse_schema(new_schema)
|
13
27
|
|
@@ -22,10 +36,9 @@ class GraphQLSchema < Thor
|
|
22
36
|
else
|
23
37
|
print_changes(result)
|
24
38
|
end
|
39
|
+
result
|
25
40
|
end
|
26
41
|
|
27
|
-
private
|
28
|
-
|
29
42
|
def print_changes(result)
|
30
43
|
say "Detected the following changes between schemas:"
|
31
44
|
say "\n"
|
@@ -8,23 +8,28 @@ 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", "
|
25
|
-
spec.add_dependency "thor", "
|
29
|
+
spec.add_dependency "graphql", ">= 1.10", "< 3.0"
|
30
|
+
spec.add_dependency "thor", ">= 0.19", "< 2.0"
|
31
|
+
spec.add_dependency "bundler", ">= 1.14"
|
26
32
|
|
27
|
-
spec.add_development_dependency "bundler", "~> 1.14"
|
28
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
34
|
spec.add_development_dependency "minitest", "~> 5.10"
|
30
35
|
spec.add_development_dependency "pry-byebug", "~> 3.4"
|
@@ -45,15 +45,17 @@ module GraphQL
|
|
45
45
|
|
46
46
|
def initialize(removed_type)
|
47
47
|
@removed_type = removed_type
|
48
|
-
@criticality = Changes::Criticality.breaking
|
48
|
+
@criticality = Changes::Criticality.breaking(
|
49
|
+
reason: "Removing a type is a breaking change. It is preferable to deprecate and remove all references to this type first."
|
50
|
+
)
|
49
51
|
end
|
50
52
|
|
51
53
|
def message
|
52
|
-
"Type `#{removed_type.
|
54
|
+
"Type `#{removed_type.graphql_name}` was removed"
|
53
55
|
end
|
54
56
|
|
55
57
|
def path
|
56
|
-
removed_type.
|
58
|
+
removed_type.path
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
@@ -66,11 +68,11 @@ module GraphQL
|
|
66
68
|
end
|
67
69
|
|
68
70
|
def message
|
69
|
-
"Directive `#{directive.
|
71
|
+
"Directive `#{directive.graphql_name}` was removed"
|
70
72
|
end
|
71
73
|
|
72
74
|
def path
|
73
|
-
"@#{directive.
|
75
|
+
"@#{directive.graphql_name}"
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
@@ -80,15 +82,17 @@ module GraphQL
|
|
80
82
|
def initialize(old_type, new_type)
|
81
83
|
@old_type = old_type
|
82
84
|
@new_type = new_type
|
83
|
-
@criticality = Changes::Criticality.breaking
|
85
|
+
@criticality = Changes::Criticality.breaking(
|
86
|
+
reason: "Changing the kind of a type is a breaking change because it can cause existing queries to error. For example, turning an object type to a scalar type would break queries that define a selection set for this type."
|
87
|
+
)
|
84
88
|
end
|
85
89
|
|
86
90
|
def message
|
87
|
-
"`#{old_type.
|
91
|
+
"`#{old_type.graphql_name}` kind changed from `#{old_type.kind}` to `#{new_type.kind}`"
|
88
92
|
end
|
89
93
|
|
90
94
|
def path
|
91
|
-
old_type.
|
95
|
+
old_type.path
|
92
96
|
end
|
93
97
|
end
|
94
98
|
|
@@ -98,15 +102,17 @@ module GraphQL
|
|
98
102
|
def initialize(enum_type, enum_value)
|
99
103
|
@enum_value = enum_value
|
100
104
|
@enum_type = enum_type
|
101
|
-
@criticality = Changes::Criticality.breaking
|
105
|
+
@criticality = Changes::Criticality.breaking(
|
106
|
+
reason: "Removing an enum value will cause existing queries that use this enum value to error."
|
107
|
+
)
|
102
108
|
end
|
103
109
|
|
104
110
|
def message
|
105
|
-
"Enum value `#{enum_value.
|
111
|
+
"Enum value `#{enum_value.graphql_name}` was removed from enum `#{enum_type.graphql_name}`"
|
106
112
|
end
|
107
113
|
|
108
114
|
def path
|
109
|
-
|
115
|
+
enum_value.path
|
110
116
|
end
|
111
117
|
end
|
112
118
|
|
@@ -116,15 +122,17 @@ module GraphQL
|
|
116
122
|
def initialize(union_type, union_member)
|
117
123
|
@union_member = union_member
|
118
124
|
@union_type = union_type
|
119
|
-
@criticality = Changes::Criticality.breaking
|
125
|
+
@criticality = Changes::Criticality.breaking(
|
126
|
+
reason: "Removing a union member from a union can cause existing queries that use this union member in a fragment spread to error."
|
127
|
+
)
|
120
128
|
end
|
121
129
|
|
122
130
|
def message
|
123
|
-
"Union member `#{union_member.
|
131
|
+
"Union member `#{union_member.graphql_name}` was removed from Union type `#{union_type.graphql_name}`"
|
124
132
|
end
|
125
133
|
|
126
134
|
def path
|
127
|
-
union_type.
|
135
|
+
union_type.path
|
128
136
|
end
|
129
137
|
end
|
130
138
|
|
@@ -134,15 +142,17 @@ module GraphQL
|
|
134
142
|
def initialize(input_object_type, field)
|
135
143
|
@input_object_type = input_object_type
|
136
144
|
@field = field
|
137
|
-
@criticality = Changes::Criticality.breaking
|
145
|
+
@criticality = Changes::Criticality.breaking(
|
146
|
+
reason: "Removing an input field will cause existing queries that use this input field to error."
|
147
|
+
)
|
138
148
|
end
|
139
149
|
|
140
150
|
def message
|
141
|
-
"Input field `#{field.
|
151
|
+
"Input field `#{field.graphql_name}` was removed from input object type `#{input_object_type.graphql_name}`"
|
142
152
|
end
|
143
153
|
|
144
154
|
def path
|
145
|
-
|
155
|
+
field.path
|
146
156
|
end
|
147
157
|
end
|
148
158
|
|
@@ -153,15 +163,17 @@ module GraphQL
|
|
153
163
|
@object_type = object_type
|
154
164
|
@field = field
|
155
165
|
@argument = argument
|
156
|
-
@criticality = Changes::Criticality.breaking
|
166
|
+
@criticality = Changes::Criticality.breaking(
|
167
|
+
reason: "Removing a field argument is a breaking change because it will cause existing queries that use this argument to error."
|
168
|
+
)
|
157
169
|
end
|
158
170
|
|
159
171
|
def message
|
160
|
-
"Argument `#{argument.
|
172
|
+
"Argument `#{argument.graphql_name}: #{argument.type.graphql_name}` was removed from field `#{object_type.graphql_name}.#{field.graphql_name}`"
|
161
173
|
end
|
162
174
|
|
163
175
|
def path
|
164
|
-
|
176
|
+
argument.path
|
165
177
|
end
|
166
178
|
end
|
167
179
|
|
@@ -175,11 +187,11 @@ module GraphQL
|
|
175
187
|
end
|
176
188
|
|
177
189
|
def message
|
178
|
-
"Argument `#{argument.
|
190
|
+
"Argument `#{argument.graphql_name}` was removed from directive `#{directive.graphql_name}`"
|
179
191
|
end
|
180
192
|
|
181
193
|
def path
|
182
|
-
["@#{directive.
|
194
|
+
["@#{directive.graphql_name}", argument.graphql_name].join('.')
|
183
195
|
end
|
184
196
|
end
|
185
197
|
|
@@ -193,7 +205,7 @@ module GraphQL
|
|
193
205
|
end
|
194
206
|
|
195
207
|
def message
|
196
|
-
"Schema query root has changed from `#{old_schema.query.
|
208
|
+
"Schema query root has changed from `#{old_schema.query.graphql_name}` to `#{new_schema.query.graphql_name}`"
|
197
209
|
end
|
198
210
|
|
199
211
|
def path
|
@@ -207,15 +219,25 @@ module GraphQL
|
|
207
219
|
def initialize(object_type, field)
|
208
220
|
@object_type = object_type
|
209
221
|
@field = field
|
210
|
-
|
222
|
+
|
223
|
+
if field.deprecation_reason
|
224
|
+
@criticality = Changes::Criticality.breaking(
|
225
|
+
reason: "Removing a deprecated field is a breaking change. Before removing it, you may want" \
|
226
|
+
"to look at the field's usage to see the impact of removing the field."
|
227
|
+
)
|
228
|
+
else
|
229
|
+
@criticality = Changes::Criticality.breaking(
|
230
|
+
reason: "Removing a field is a breaking change. It is preferable to deprecate the field before removing it."
|
231
|
+
)
|
232
|
+
end
|
211
233
|
end
|
212
234
|
|
213
235
|
def message
|
214
|
-
"Field `#{field.
|
236
|
+
"Field `#{field.graphql_name}` was removed from object type `#{object_type.graphql_name}`"
|
215
237
|
end
|
216
238
|
|
217
239
|
def path
|
218
|
-
[object_type.
|
240
|
+
[object_type.graphql_name, field.graphql_name].join(".")
|
219
241
|
end
|
220
242
|
end
|
221
243
|
|
@@ -229,11 +251,11 @@ module GraphQL
|
|
229
251
|
end
|
230
252
|
|
231
253
|
def message
|
232
|
-
"Location `#{location}` was removed from directive `#{directive.
|
254
|
+
"Location `#{location}` was removed from directive `#{directive.graphql_name}`"
|
233
255
|
end
|
234
256
|
|
235
257
|
def path
|
236
|
-
"@#{directive.
|
258
|
+
"@#{directive.graphql_name}"
|
237
259
|
end
|
238
260
|
end
|
239
261
|
|
@@ -243,15 +265,17 @@ module GraphQL
|
|
243
265
|
def initialize(interface, object_type)
|
244
266
|
@interface = interface
|
245
267
|
@object_type = object_type
|
246
|
-
@criticality = Changes::Criticality.breaking
|
268
|
+
@criticality = Changes::Criticality.breaking(
|
269
|
+
reason: "Removing an interface from an object type can cause existing queries that use this in a fragment spread to error."
|
270
|
+
)
|
247
271
|
end
|
248
272
|
|
249
273
|
def message
|
250
|
-
"`#{object_type.
|
274
|
+
"`#{object_type.graphql_name}` object type no longer implements `#{interface.graphql_name}` interface"
|
251
275
|
end
|
252
276
|
|
253
277
|
def path
|
254
|
-
object_type.
|
278
|
+
object_type.path
|
255
279
|
end
|
256
280
|
end
|
257
281
|
|
@@ -267,19 +291,19 @@ module GraphQL
|
|
267
291
|
end
|
268
292
|
|
269
293
|
def message
|
270
|
-
"Field `#{
|
294
|
+
"Field `#{old_field.path}` changed type from `#{old_field.type.to_type_signature}` to `#{new_field.type.to_type_signature}`"
|
271
295
|
end
|
272
296
|
|
273
297
|
def criticality
|
274
298
|
if safe_change_for_field?(old_field.type, new_field.type)
|
275
299
|
Changes::Criticality.non_breaking
|
276
300
|
else
|
277
|
-
Changes::Criticality.breaking
|
301
|
+
Changes::Criticality.breaking # TODO - Add reason
|
278
302
|
end
|
279
303
|
end
|
280
304
|
|
281
305
|
def path
|
282
|
-
|
306
|
+
old_field.path
|
283
307
|
end
|
284
308
|
end
|
285
309
|
|
@@ -294,7 +318,9 @@ module GraphQL
|
|
294
318
|
reason: "Changing an input field from non-null to null is considered non-breaking"
|
295
319
|
)
|
296
320
|
else
|
297
|
-
@criticality = Changes::Criticality.breaking
|
321
|
+
@criticality = Changes::Criticality.breaking(
|
322
|
+
reason: "Changing the type of an input field can cause existing queries that use this field to error."
|
323
|
+
)
|
298
324
|
end
|
299
325
|
|
300
326
|
@input_type = input_type
|
@@ -303,11 +329,11 @@ module GraphQL
|
|
303
329
|
end
|
304
330
|
|
305
331
|
def message
|
306
|
-
"Input field `#{
|
332
|
+
"Input field `#{path}` changed type from `#{old_input_field.type.to_type_signature}` to `#{new_input_field.type.to_type_signature}`"
|
307
333
|
end
|
308
334
|
|
309
335
|
def path
|
310
|
-
|
336
|
+
old_input_field.path
|
311
337
|
end
|
312
338
|
end
|
313
339
|
|
@@ -322,7 +348,9 @@ module GraphQL
|
|
322
348
|
reason: "Changing an input field from non-null to null is considered non-breaking"
|
323
349
|
)
|
324
350
|
else
|
325
|
-
@criticality = Changes::Criticality.breaking
|
351
|
+
@criticality = Changes::Criticality.breaking(
|
352
|
+
reason: "Changing the type of a field's argument can cause existing queries that use this argument to error."
|
353
|
+
)
|
326
354
|
end
|
327
355
|
|
328
356
|
@type = type
|
@@ -332,12 +360,12 @@ module GraphQL
|
|
332
360
|
end
|
333
361
|
|
334
362
|
def message
|
335
|
-
"Type for argument `#{new_argument.
|
336
|
-
" 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}`"
|
337
365
|
end
|
338
366
|
|
339
367
|
def path
|
340
|
-
|
368
|
+
old_argument.path
|
341
369
|
end
|
342
370
|
end
|
343
371
|
|
@@ -361,12 +389,12 @@ module GraphQL
|
|
361
389
|
end
|
362
390
|
|
363
391
|
def message
|
364
|
-
"Type for argument `#{new_argument.
|
365
|
-
" 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}`"
|
366
394
|
end
|
367
395
|
|
368
396
|
def path
|
369
|
-
["@#{directive.
|
397
|
+
["@#{directive.graphql_name}", old_argument.graphql_name].join('.')
|
370
398
|
end
|
371
399
|
end
|
372
400
|
|
@@ -423,16 +451,16 @@ module GraphQL
|
|
423
451
|
end
|
424
452
|
|
425
453
|
def message
|
426
|
-
if old_argument.default_value.nil?
|
427
|
-
"Default value `#{new_argument.default_value}` was added to argument `#{new_argument.
|
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}`"
|
428
456
|
else
|
429
|
-
"Default value for argument `#{new_argument.
|
457
|
+
"Default value for argument `#{new_argument.graphql_name}` on field `#{field.path}` changed"\
|
430
458
|
" from `#{old_argument.default_value}` to `#{new_argument.default_value}`"
|
431
459
|
end
|
432
460
|
end
|
433
461
|
|
434
462
|
def path
|
435
|
-
|
463
|
+
old_argument.path
|
436
464
|
end
|
437
465
|
end
|
438
466
|
|
@@ -450,12 +478,12 @@ module GraphQL
|
|
450
478
|
end
|
451
479
|
|
452
480
|
def message
|
453
|
-
"Input field `#{
|
481
|
+
"Input field `#{path}` default changed"\
|
454
482
|
" from `#{old_field.default_value}` to `#{new_field.default_value}`"
|
455
483
|
end
|
456
484
|
|
457
485
|
def path
|
458
|
-
|
486
|
+
old_field.path
|
459
487
|
end
|
460
488
|
end
|
461
489
|
|
@@ -473,12 +501,12 @@ module GraphQL
|
|
473
501
|
end
|
474
502
|
|
475
503
|
def message
|
476
|
-
"Default value for argument `#{new_argument.
|
504
|
+
"Default value for argument `#{new_argument.graphql_name}` on directive `#{directive.graphql_name}` changed"\
|
477
505
|
" from `#{old_argument.default_value}` to `#{new_argument.default_value}`"
|
478
506
|
end
|
479
507
|
|
480
508
|
def path
|
481
|
-
["@#{directive.
|
509
|
+
["@#{directive.graphql_name}", new_argument.graphql_name].join(".")
|
482
510
|
end
|
483
511
|
end
|
484
512
|
|
@@ -495,11 +523,11 @@ module GraphQL
|
|
495
523
|
end
|
496
524
|
|
497
525
|
def message
|
498
|
-
"Enum value `#{enum_value.
|
526
|
+
"Enum value `#{enum_value.graphql_name}` was added to enum `#{enum_type.graphql_name}`"
|
499
527
|
end
|
500
528
|
|
501
529
|
def path
|
502
|
-
|
530
|
+
enum_value.path
|
503
531
|
end
|
504
532
|
end
|
505
533
|
|
@@ -516,11 +544,11 @@ module GraphQL
|
|
516
544
|
end
|
517
545
|
|
518
546
|
def message
|
519
|
-
"Union member `#{union_member.
|
547
|
+
"Union member `#{union_member.graphql_name}` was added to Union type `#{union_type.graphql_name}`"
|
520
548
|
end
|
521
549
|
|
522
550
|
def path
|
523
|
-
union_type.
|
551
|
+
union_type.path
|
524
552
|
end
|
525
553
|
end
|
526
554
|
|
@@ -537,11 +565,11 @@ module GraphQL
|
|
537
565
|
end
|
538
566
|
|
539
567
|
def message
|
540
|
-
"`#{object_type.
|
568
|
+
"`#{object_type.graphql_name}` object implements `#{interface.graphql_name}` interface"
|
541
569
|
end
|
542
570
|
|
543
571
|
def path
|
544
|
-
object_type.
|
572
|
+
object_type.path
|
545
573
|
end
|
546
574
|
end
|
547
575
|
|
@@ -551,8 +579,8 @@ module GraphQL
|
|
551
579
|
attr_reader :input_object_type, :field, :criticality
|
552
580
|
|
553
581
|
def initialize(input_object_type, field)
|
554
|
-
@criticality = if field.type.non_null?
|
555
|
-
Changes::Criticality.breaking
|
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.")
|
556
584
|
else
|
557
585
|
Changes::Criticality.non_breaking
|
558
586
|
end
|
@@ -562,11 +590,11 @@ module GraphQL
|
|
562
590
|
end
|
563
591
|
|
564
592
|
def message
|
565
|
-
"Input field `#{field.
|
593
|
+
"Input field `#{field.graphql_name}` was added to input object type `#{input_object_type.graphql_name}`"
|
566
594
|
end
|
567
595
|
|
568
596
|
def path
|
569
|
-
|
597
|
+
field.path
|
570
598
|
end
|
571
599
|
end
|
572
600
|
|
@@ -574,8 +602,8 @@ module GraphQL
|
|
574
602
|
attr_reader :type, :field, :argument, :criticality
|
575
603
|
|
576
604
|
def initialize(type, field, argument)
|
577
|
-
@criticality = if argument.type.non_null?
|
578
|
-
Changes::Criticality.breaking
|
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.")
|
579
607
|
else
|
580
608
|
Changes::Criticality.non_breaking
|
581
609
|
end
|
@@ -586,11 +614,11 @@ module GraphQL
|
|
586
614
|
end
|
587
615
|
|
588
616
|
def message
|
589
|
-
"Argument `#{argument.
|
617
|
+
"Argument `#{argument.graphql_name}: #{argument.type.graphql_name}` added to field `#{field.path}`"
|
590
618
|
end
|
591
619
|
|
592
620
|
def path
|
593
|
-
|
621
|
+
argument.path
|
594
622
|
end
|
595
623
|
end
|
596
624
|
|
@@ -603,11 +631,11 @@ module GraphQL
|
|
603
631
|
end
|
604
632
|
|
605
633
|
def message
|
606
|
-
"Type `#{type.
|
634
|
+
"Type `#{type.graphql_name}` was added"
|
607
635
|
end
|
608
636
|
|
609
637
|
def path
|
610
|
-
type.
|
638
|
+
type.path
|
611
639
|
end
|
612
640
|
end
|
613
641
|
|
@@ -620,11 +648,11 @@ module GraphQL
|
|
620
648
|
end
|
621
649
|
|
622
650
|
def message
|
623
|
-
"Directive `#{directive.
|
651
|
+
"Directive `#{directive.graphql_name}` was added"
|
624
652
|
end
|
625
653
|
|
626
654
|
def path
|
627
|
-
"@#{directive.
|
655
|
+
"@#{directive.graphql_name}"
|
628
656
|
end
|
629
657
|
end
|
630
658
|
|
@@ -638,11 +666,11 @@ module GraphQL
|
|
638
666
|
end
|
639
667
|
|
640
668
|
def message
|
641
|
-
"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}`"
|
642
670
|
end
|
643
671
|
|
644
672
|
def path
|
645
|
-
old_type.
|
673
|
+
old_type.path
|
646
674
|
end
|
647
675
|
end
|
648
676
|
|
@@ -657,12 +685,12 @@ module GraphQL
|
|
657
685
|
end
|
658
686
|
|
659
687
|
def message
|
660
|
-
"Description for enum value `#{
|
688
|
+
"Description for enum value `#{new_enum_value.path}` changed from " \
|
661
689
|
"`#{old_enum_value.description}` to `#{new_enum_value.description}`"
|
662
690
|
end
|
663
691
|
|
664
692
|
def path
|
665
|
-
|
693
|
+
old_enum_value.path
|
666
694
|
end
|
667
695
|
end
|
668
696
|
|
@@ -678,16 +706,15 @@ module GraphQL
|
|
678
706
|
|
679
707
|
def message
|
680
708
|
if old_enum_value.deprecation_reason
|
681
|
-
"Enum value `#{
|
709
|
+
"Enum value `#{new_enum_value.path}` deprecation reason changed " \
|
682
710
|
"from `#{old_enum_value.deprecation_reason}` to `#{new_enum_value.deprecation_reason}`"
|
683
711
|
else
|
684
|
-
"Enum value `#{
|
685
|
-
" `#{new_enum_value.deprecation_reason}`"
|
712
|
+
"Enum value `#{new_enum_value.path}` was deprecated with reason `#{new_enum_value.deprecation_reason}`"
|
686
713
|
end
|
687
714
|
end
|
688
715
|
|
689
716
|
def path
|
690
|
-
|
717
|
+
old_enum_value.path
|
691
718
|
end
|
692
719
|
end
|
693
720
|
|
@@ -702,12 +729,12 @@ module GraphQL
|
|
702
729
|
end
|
703
730
|
|
704
731
|
def message
|
705
|
-
"Input field `#{
|
732
|
+
"Input field `#{old_field.path}` description changed"\
|
706
733
|
" from `#{old_field.description}` to `#{new_field.description}`"
|
707
734
|
end
|
708
735
|
|
709
736
|
def path
|
710
|
-
|
737
|
+
old_field.path
|
711
738
|
end
|
712
739
|
end
|
713
740
|
|
@@ -721,12 +748,12 @@ module GraphQL
|
|
721
748
|
end
|
722
749
|
|
723
750
|
def message
|
724
|
-
"Directive `#{new_directive.
|
751
|
+
"Directive `#{new_directive.graphql_name}` description changed"\
|
725
752
|
" from `#{old_directive.description}` to `#{new_directive.description}`"
|
726
753
|
end
|
727
754
|
|
728
755
|
def path
|
729
|
-
"@#{old_directive.
|
756
|
+
"@#{old_directive.graphql_name}"
|
730
757
|
end
|
731
758
|
end
|
732
759
|
|
@@ -741,12 +768,12 @@ module GraphQL
|
|
741
768
|
end
|
742
769
|
|
743
770
|
def message
|
744
|
-
"Field `#{
|
771
|
+
"Field `#{old_field.path}` description changed"\
|
745
772
|
" from `#{old_field.description}` to `#{new_field.description}`"
|
746
773
|
end
|
747
774
|
|
748
775
|
def path
|
749
|
-
|
776
|
+
old_field.path
|
750
777
|
end
|
751
778
|
end
|
752
779
|
|
@@ -762,12 +789,12 @@ module GraphQL
|
|
762
789
|
end
|
763
790
|
|
764
791
|
def message
|
765
|
-
"Description for argument `#{new_argument.
|
792
|
+
"Description for argument `#{new_argument.graphql_name}` on field `#{field.path}` changed"\
|
766
793
|
" from `#{old_argument.description}` to `#{new_argument.description}`"
|
767
794
|
end
|
768
795
|
|
769
796
|
def path
|
770
|
-
|
797
|
+
old_argument.path
|
771
798
|
end
|
772
799
|
end
|
773
800
|
|
@@ -782,12 +809,12 @@ module GraphQL
|
|
782
809
|
end
|
783
810
|
|
784
811
|
def message
|
785
|
-
"Description for argument `#{new_argument.
|
812
|
+
"Description for argument `#{new_argument.graphql_name}` on directive `#{directive.graphql_name}` changed"\
|
786
813
|
" from `#{old_argument.description}` to `#{new_argument.description}`"
|
787
814
|
end
|
788
815
|
|
789
816
|
def path
|
790
|
-
["@#{directive.
|
817
|
+
["@#{directive.graphql_name}", old_argument.graphql_name].join(".")
|
791
818
|
end
|
792
819
|
end
|
793
820
|
|
@@ -802,12 +829,12 @@ module GraphQL
|
|
802
829
|
end
|
803
830
|
|
804
831
|
def message
|
805
|
-
"Deprecation reason on field `#{
|
832
|
+
"Deprecation reason on field `#{new_field.path}` has changed "\
|
806
833
|
"from `#{old_field.deprecation_reason}` to `#{new_field.deprecation_reason}`"
|
807
834
|
end
|
808
835
|
|
809
836
|
def path
|
810
|
-
|
837
|
+
old_field.path
|
811
838
|
end
|
812
839
|
end
|
813
840
|
|
@@ -821,11 +848,11 @@ module GraphQL
|
|
821
848
|
end
|
822
849
|
|
823
850
|
def message
|
824
|
-
"Field `#{field.
|
851
|
+
"Field `#{field.graphql_name}` was added to object type `#{object_type.graphql_name}`"
|
825
852
|
end
|
826
853
|
|
827
854
|
def path
|
828
|
-
[object_type.
|
855
|
+
[object_type.graphql_name, field.graphql_name].join(".")
|
829
856
|
end
|
830
857
|
end
|
831
858
|
|
@@ -839,11 +866,11 @@ module GraphQL
|
|
839
866
|
end
|
840
867
|
|
841
868
|
def message
|
842
|
-
"Location `#{location}` was added to directive `#{directive.
|
869
|
+
"Location `#{location}` was added to directive `#{directive.graphql_name}`"
|
843
870
|
end
|
844
871
|
|
845
872
|
def path
|
846
|
-
"@#{directive.
|
873
|
+
"@#{directive.graphql_name}"
|
847
874
|
end
|
848
875
|
end
|
849
876
|
|
@@ -1005,7 +1032,7 @@ module GraphQL
|
|
1005
1032
|
end
|
1006
1033
|
|
1007
1034
|
def message
|
1008
|
-
"Argument `#{argument.
|
1035
|
+
"Argument `#{argument.graphql_name}` was added to directive `#{directive.graphql_name}`"
|
1009
1036
|
end
|
1010
1037
|
end
|
1011
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.
|
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)
|
@@ -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.
|
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 != 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.
|
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
|
@@ -40,22 +40,26 @@ module GraphQL
|
|
40
40
|
)
|
41
41
|
|
42
42
|
def interface_removals
|
43
|
-
removed = old_interfaces
|
44
|
-
removed.map { |
|
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
|
49
|
-
added.map { |
|
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.
|
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.
|
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
|
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 != 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
|
29
|
+
filter_types(old_possible_types, new_possible_types)
|
30
30
|
end
|
31
31
|
|
32
32
|
def added_possible_types
|
33
|
-
new_possible_types
|
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
|
@@ -35,7 +35,7 @@ module GraphQL
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def self.parse_schema(schema)
|
38
|
-
if 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,55 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-schema_comparator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
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:
|
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
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
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
|
-
version: '1.
|
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
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '0.19'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.0'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
|
-
- - "
|
47
|
+
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
49
|
version: '0.19'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '2.0'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: bundler
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
44
56
|
requirements:
|
45
|
-
- - "
|
57
|
+
- - ">="
|
46
58
|
- !ruby/object:Gem::Version
|
47
59
|
version: '1.14'
|
48
|
-
type: :
|
60
|
+
type: :runtime
|
49
61
|
prerelease: false
|
50
62
|
version_requirements: !ruby/object:Gem::Requirement
|
51
63
|
requirements:
|
52
|
-
- - "
|
64
|
+
- - ">="
|
53
65
|
- !ruby/object:Gem::Version
|
54
66
|
version: '1.14'
|
55
67
|
- !ruby/object:Gem::Dependency
|
@@ -94,7 +106,7 @@ dependencies:
|
|
94
106
|
- - "~>"
|
95
107
|
- !ruby/object:Gem::Version
|
96
108
|
version: '3.4'
|
97
|
-
description: GraphQL::SchemaComparator compares two GraphQL schemas given their
|
109
|
+
description: GraphQL::SchemaComparator compares two GraphQL schemas given their SDL
|
98
110
|
and returns a list of changes.
|
99
111
|
email:
|
100
112
|
- mgiroux0@gmail.com
|
@@ -104,8 +116,8 @@ executables:
|
|
104
116
|
extensions: []
|
105
117
|
extra_rdoc_files: []
|
106
118
|
files:
|
119
|
+
- ".github/workflows/ci.yml"
|
107
120
|
- ".gitignore"
|
108
|
-
- ".travis.yml"
|
109
121
|
- CHANGELOG.md
|
110
122
|
- CODE_OF_CONDUCT.md
|
111
123
|
- Gemfile
|
@@ -116,6 +128,9 @@ files:
|
|
116
128
|
- bin/graphql-schema
|
117
129
|
- bin/schema_comparator
|
118
130
|
- bin/setup
|
131
|
+
- gemfiles/graphql-head.gemfile
|
132
|
+
- gemfiles/graphql1.10.gemfile
|
133
|
+
- gemfiles/graphql1.13.gemfile
|
119
134
|
- graphql-schema_comparator.gemspec
|
120
135
|
- lib/graphql/schema_comparator.rb
|
121
136
|
- lib/graphql/schema_comparator/changes.rb
|
@@ -126,7 +141,6 @@ files:
|
|
126
141
|
- lib/graphql/schema_comparator/diff/directive_argument.rb
|
127
142
|
- lib/graphql/schema_comparator/diff/enum.rb
|
128
143
|
- lib/graphql/schema_comparator/diff/field.rb
|
129
|
-
- lib/graphql/schema_comparator/diff/has_directives.rb
|
130
144
|
- lib/graphql/schema_comparator/diff/input_field.rb
|
131
145
|
- lib/graphql/schema_comparator/diff/input_object.rb
|
132
146
|
- lib/graphql/schema_comparator/diff/interface.rb
|
@@ -136,10 +150,14 @@ files:
|
|
136
150
|
- lib/graphql/schema_comparator/result.rb
|
137
151
|
- lib/graphql/schema_comparator/version.rb
|
138
152
|
- schema.graphql
|
139
|
-
homepage:
|
153
|
+
homepage: https://github.com/xuorig/graphql-schema_comparator
|
140
154
|
licenses:
|
141
155
|
- MIT
|
142
|
-
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
|
143
161
|
post_install_message:
|
144
162
|
rdoc_options: []
|
145
163
|
require_paths:
|
@@ -155,8 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
173
|
- !ruby/object:Gem::Version
|
156
174
|
version: '0'
|
157
175
|
requirements: []
|
158
|
-
|
159
|
-
rubygems_version: 2.6.8
|
176
|
+
rubygems_version: 3.0.3.1
|
160
177
|
signing_key:
|
161
178
|
specification_version: 4
|
162
179
|
summary: Compare GraphQL schemas and get the changes that happened.
|
data/.travis.yml
DELETED
File without changes
|