graphql-schema_comparator 0.6.0 → 0.6.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
2
  SHA1:
3
- metadata.gz: 3b2c5111538092113b88552e2d85930eea51b4c0
4
- data.tar.gz: 3a3b4d43916961515caa915c51e0c0b0370c1395
3
+ metadata.gz: fb19e37d9e3d7037094e788cce01bd91fe88fbe6
4
+ data.tar.gz: dd33278458a8405503abf0c34b8fbd6fb565a5c5
5
5
  SHA512:
6
- metadata.gz: 00c6e2702e8bb9c1f34b1d9a777a3b63cc0cb6f56aa78f76bf14c04aee0997e6e690f79de956d46da31be9298a98ff72413d5cd77f18b514cd0b6b8a02021f76
7
- data.tar.gz: b74179eb8941cf2985f9dda75219b28b001e4c771db5db3d49e380cc98bc94c625d720dd7bf4cb88ddef6e51672b0a50b136b92da3e6dbfc6af3c13874e8c65f
6
+ metadata.gz: 5a6592586307a89a97e5d62dcf623310a8d09c4dd9c4c5a496f9556649cbb56ecdc3c4a2de97494e27b5c04d9e97a816e8e02a20e52a532f7fc672165f13af69
7
+ data.tar.gz: a4c7eaf05826ce093c6772a7a3aa024e73d44b2df7dad968e4ae161188fbbe9dfaec608a6e78e242ebc350ddb55be5d271412d0548aa64dcae65a4072f764fcb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.1 (May 21rst 2019)
4
+
5
+ - Added a bunch of reasons to breaking changes (#17)
6
+ - Relaxed Thor Dependency
7
+ - Add `verify` task for CI usage which returns exit codes depending on breaking changes (#24)
8
+
3
9
  ## 0.6.0 (Feb 28th 2018)
4
10
 
5
11
  ### New Features
data/README.md CHANGED
@@ -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 ``#criticality` method which returns a `Changes::Criticality` object.
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:
@@ -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"
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
 
24
24
  spec.add_dependency "graphql", "~> 1.6"
25
- spec.add_dependency "thor", "~> 0.19"
25
+ spec.add_dependency "thor", ">= 0.19", "< 2.0"
26
+ spec.add_dependency "bundler", ">= 1.14"
26
27
 
27
- spec.add_development_dependency "bundler", "~> 1.14"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
29
29
  spec.add_development_dependency "minitest", "~> 5.10"
30
30
  spec.add_development_dependency "pry-byebug", "~> 3.4"
@@ -45,7 +45,9 @@ 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
@@ -80,7 +82,9 @@ 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
@@ -98,7 +102,9 @@ 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
@@ -116,7 +122,9 @@ 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
@@ -134,7 +142,9 @@ 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
@@ -153,7 +163,9 @@ 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
@@ -207,7 +219,17 @@ module GraphQL
207
219
  def initialize(object_type, field)
208
220
  @object_type = object_type
209
221
  @field = field
210
- @criticality = Changes::Criticality.breaking
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
@@ -243,7 +265,9 @@ 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
@@ -274,7 +298,7 @@ module GraphQL
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
 
@@ -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
@@ -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
@@ -552,7 +580,7 @@ module GraphQL
552
580
 
553
581
  def initialize(input_object_type, field)
554
582
  @criticality = if field.type.non_null?
555
- Changes::Criticality.breaking
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.")
556
584
  else
557
585
  Changes::Criticality.non_breaking
558
586
  end
@@ -575,7 +603,7 @@ module GraphQL
575
603
 
576
604
  def initialize(type, field, argument)
577
605
  @criticality = if argument.type.non_null?
578
- Changes::Criticality.breaking
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.")
579
607
  else
580
608
  Changes::Criticality.non_breaking
581
609
  end
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module SchemaComparator
3
- VERSION = "0.6.0"
3
+ VERSION = "0.6.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-schema_comparator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.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: 2018-02-28 00:00:00.000000000 Z
11
+ date: 2019-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -28,28 +28,34 @@ dependencies:
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.19'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '0.19'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - "~>"
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
53
  version: '1.14'
48
- type: :development
54
+ type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - "~>"
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
60
  version: '1.14'
55
61
  - !ruby/object:Gem::Dependency