graphql-schema_comparator 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +13 -0
- data/lib/graphql/schema_comparator/changes.rb +35 -4
- data/lib/graphql/schema_comparator/diff/enum.rb +14 -14
- data/lib/graphql/schema_comparator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bae47fd797c861e89911fafe37a7483acf01945e
|
4
|
+
data.tar.gz: 3a3ef6822c996be20aae3d0e3785ae8fa75549e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6449c7c8044ebe1c5d586e9a6a99e308ab3b24bd8cee27996da25ff4b3c2793462d4865d8b9de491adec6e58ca2b2492fdc6bb273549831a4f0b9b4764516061
|
7
|
+
data.tar.gz: c3bc07672039aa72c0cb8de702ffa29357c3dd2778ae356cead4f02e242d83fd88f8bd2b9902bd831f8be7cfef8828f2130f1b1c6b9047b6ad84587098f976bc
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.3.2 (Nov 14 2017)
|
4
|
+
|
5
|
+
### New Features
|
6
|
+
|
7
|
+
Added changes:
|
8
|
+
|
9
|
+
- `EnumValueDeprecated`
|
10
|
+
- `EnumValueDescriptionChanged`
|
11
|
+
|
12
|
+
### Bug fixes
|
13
|
+
|
14
|
+
Fix issue in Enum differ (https://github.com/xuorig/graphql-schema_comparator/issues/9)
|
15
|
+
|
3
16
|
## 0.3.1 (Nov 13 2017)
|
4
17
|
|
5
18
|
### Bug Fixes
|
@@ -296,15 +296,46 @@ module GraphQL
|
|
296
296
|
end
|
297
297
|
end
|
298
298
|
|
299
|
-
# TODO
|
300
299
|
class EnumValueDescriptionChanged < AbstractChange
|
301
|
-
|
300
|
+
attr_reader :enum, :old_enum_value, :new_enum_value
|
301
|
+
|
302
|
+
def initialize(enum, old_enum_value, new_enum_value)
|
303
|
+
@enum = enum
|
304
|
+
@old_enum_value = old_enum_value
|
305
|
+
@new_enum_value = new_enum_value
|
306
|
+
end
|
307
|
+
|
308
|
+
def message
|
309
|
+
"Description for enum value `#{enum.name}.#{new_enum_value.name}` changed from " \
|
310
|
+
"`#{old_enum_value.description}` to `#{new_enum_value.description}`"
|
311
|
+
end
|
312
|
+
|
313
|
+
def breaking?
|
314
|
+
false
|
302
315
|
end
|
303
316
|
end
|
304
317
|
|
305
|
-
# TODO
|
306
318
|
class EnumValueDeprecated < AbstractChange
|
307
|
-
|
319
|
+
attr_reader :enum, :old_enum_value, :new_enum_value
|
320
|
+
|
321
|
+
def initialize(enum, old_enum_value, new_enum_value)
|
322
|
+
@enum = enum
|
323
|
+
@old_enum_value = old_enum_value
|
324
|
+
@new_enum_value = new_enum_value
|
325
|
+
end
|
326
|
+
|
327
|
+
def message
|
328
|
+
if old_enum_value.deprecation_reason
|
329
|
+
"Enum value `#{enum.name}.#{new_enum_value.name}` deprecation reason changed " \
|
330
|
+
"from `#{old_enum_value.deprecation_reason}` to `#{new_enum_value.deprecation_reason}`"
|
331
|
+
else
|
332
|
+
"Enum value `#{enum.name}.#{new_enum_value.name}` was deprecated with reason" \
|
333
|
+
" `#{new_enum_value.deprecation_reason}`"
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def breaking?
|
338
|
+
false
|
308
339
|
end
|
309
340
|
end
|
310
341
|
|
@@ -2,29 +2,29 @@ module GraphQL
|
|
2
2
|
module SchemaComparator
|
3
3
|
module Diff
|
4
4
|
class Enum
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@
|
5
|
+
def initialize(old_enum, new_enum)
|
6
|
+
@old_enum = old_enum
|
7
|
+
@new_enum = new_enum
|
8
8
|
|
9
|
-
@old_values =
|
10
|
-
@new_values =
|
9
|
+
@old_values = old_enum.values
|
10
|
+
@new_values = new_enum.values
|
11
11
|
end
|
12
12
|
|
13
13
|
def diff
|
14
14
|
changes = []
|
15
15
|
|
16
|
-
changes += removed_values.map { |value| Changes::EnumValueRemoved.new(
|
17
|
-
changes += added_values.map { |value| Changes::EnumValueAdded.new(
|
16
|
+
changes += removed_values.map { |value| Changes::EnumValueRemoved.new(old_enum, value) }
|
17
|
+
changes += added_values.map { |value| Changes::EnumValueAdded.new(new_enum, value) }
|
18
18
|
|
19
19
|
each_common_value do |old_value, new_value|
|
20
20
|
# TODO: Add Directive Stuff
|
21
21
|
|
22
22
|
if old_value.description != new_value.description
|
23
|
-
changes
|
23
|
+
changes << Changes::EnumValueDescriptionChanged.new(new_enum, old_value, new_value)
|
24
24
|
end
|
25
25
|
|
26
26
|
if old_value.deprecation_reason != new_value.deprecation_reason
|
27
|
-
changes
|
27
|
+
changes << Changes::EnumValueDeprecated.new(new_enum, old_value, new_value)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -33,24 +33,24 @@ module GraphQL
|
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
-
attr_reader :
|
36
|
+
attr_reader :old_enum, :new_enum, :old_values, :new_values
|
37
37
|
|
38
38
|
def each_common_value(&block)
|
39
39
|
intersection = old_values.keys & new_values.keys
|
40
40
|
intersection.each do |common_value|
|
41
|
-
old_value =
|
42
|
-
new_value =
|
41
|
+
old_value = old_enum.values[common_value]
|
42
|
+
new_value = new_enum.values[common_value]
|
43
43
|
|
44
44
|
block.call(old_value, new_value)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def removed_values
|
49
|
-
(old_values.keys - new_values.keys).map { |removed|
|
49
|
+
(old_values.keys - new_values.keys).map { |removed| old_enum.values[removed] }
|
50
50
|
end
|
51
51
|
|
52
52
|
def added_values
|
53
|
-
(new_values.keys - old_values.keys).map { |added|
|
53
|
+
(new_values.keys - old_values.keys).map { |added| new_enum.values[added] }
|
54
54
|
end
|
55
55
|
end
|
56
56
|
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.3.
|
4
|
+
version: 0.3.2
|
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: 2017-11-
|
11
|
+
date: 2017-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|