graphql-schema_comparator 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bae47fd797c861e89911fafe37a7483acf01945e
4
- data.tar.gz: 3a3ef6822c996be20aae3d0e3785ae8fa75549e1
3
+ metadata.gz: e193c10ab21868ab4bf6fd6f3159b4d3e4a67525
4
+ data.tar.gz: 9603fd58643f3a1dabecb23ff543a646657b1f3a
5
5
  SHA512:
6
- metadata.gz: 6449c7c8044ebe1c5d586e9a6a99e308ab3b24bd8cee27996da25ff4b3c2793462d4865d8b9de491adec6e58ca2b2492fdc6bb273549831a4f0b9b4764516061
7
- data.tar.gz: c3bc07672039aa72c0cb8de702ffa29357c3dd2778ae356cead4f02e242d83fd88f8bd2b9902bd831f8be7cfef8828f2130f1b1c6b9047b6ad84587098f976bc
6
+ metadata.gz: bced670ccc797b2222231e60d930d167e1856d820722c0c4946c45fe2d84c96fcdd50f9e91089a83a82adc9f9dee212aa6636c810a48e57745ece7b7a1d48c50
7
+ data.tar.gz: ea0916f65eb4de48038077dff40add62c7fa9d5581293d1618c4b045086545b465e13aecfb0c0390f1147496d47bcee7c5ef10c09ec0c5f5cf2f4503bb04bbb8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 (Nov 27 2017)
4
+
5
+ ## Breaking Changes
6
+
7
+ - Argument and InputValue type changes are considered non
8
+ breaking if type goes from Null => Non-Null
9
+
3
10
  ## 0.3.2 (Nov 14 2017)
4
11
 
5
12
  ### New Features
@@ -1,6 +1,21 @@
1
1
  module GraphQL
2
2
  module SchemaComparator
3
3
  module Changes
4
+ module SafeTypeChange
5
+ def safe_change?(old_type, new_type)
6
+ if !old_type.kind.wraps? && !new_type.kind.wraps?
7
+ old_type == new_type
8
+ elsif old_type.kind.list? && new_type.kind.list?
9
+ safe_change?(old_type.of_type, new_type.of_type)
10
+ elsif old_type.kind.non_null?
11
+ of_type = new_type.kind.non_null? ? new_type.of_type : new_type
12
+ safe_change?(old_type.of_type, of_type)
13
+ else
14
+ false
15
+ end
16
+ end
17
+ end
18
+
4
19
  class AbstractChange
5
20
  def message
6
21
  raise NotImplementedError
@@ -793,13 +808,15 @@ module GraphQL
793
808
  end
794
809
 
795
810
  class InputFieldTypeChanged < AbstractChange
811
+ include SafeTypeChange
812
+
796
813
  attr_reader :input_type, :old_input_field, :new_input_field
797
814
 
798
815
  def initialize(input_type, old_input_field, new_input_field)
799
816
  @input_type = input_type
800
817
  @old_input_field = old_input_field
801
818
  @new_input_field = new_input_field
802
- @breaking = true
819
+ @breaking = !safe_change?(old_input_field.type, new_input_field.type)
803
820
  end
804
821
 
805
822
  def message
@@ -812,6 +829,8 @@ module GraphQL
812
829
  end
813
830
 
814
831
  class FieldArgumentTypeChanged < AbstractChange
832
+ include SafeTypeChange
833
+
815
834
  attr_reader :type, :field, :old_argument, :new_argument
816
835
 
817
836
  def initialize(type, field, old_argument, new_argument)
@@ -819,7 +838,7 @@ module GraphQL
819
838
  @field = field
820
839
  @old_argument = old_argument
821
840
  @new_argument = new_argument
822
- @breaking = true
841
+ @breaking = !safe_change?(old_argument.type, new_argument.type)
823
842
  end
824
843
 
825
844
  def message
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module SchemaComparator
3
- VERSION = "0.3.2"
3
+ VERSION = "0.4.0"
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.3.2
4
+ version: 0.4.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: 2017-11-14 00:00:00.000000000 Z
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql