hq-graphql 2.2.0 → 2.2.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
  SHA256:
3
- metadata.gz: a158f615a83d3743a038f248bc82c04285631e6575f62b5124bbb5767ab6ede9
4
- data.tar.gz: 630bea394ce6e073b1f4ee2bd62047fcf46ba433357d1c759b99d7ecf350bfec
3
+ metadata.gz: '08dfdf7baf4c44a54bdb3ecb9e0e89baacfaab9e6dda53525a0f8dded456a8c9'
4
+ data.tar.gz: 2b12d46d565e00710f49618e603c6a88f7fd09cc753d82cb8395b8e2d7f36447
5
5
  SHA512:
6
- metadata.gz: b6076f33bc12f04a7e701f2deeb7420fc44792af3e99727029196d24d68280276a15c7c8d70d875de82c3ec48e41afdc13b5578a45fbcff2ddcc0edfa8971628
7
- data.tar.gz: c85f1b1af47ddee4f049a431277ca63bb1728ab74738fe8bc1bbc0f7b31f9dedd14f12fb850045f82ff301d83729d3f896628154e0fcaecea17c117dfd6140d5
6
+ metadata.gz: 157d2faad665955ce59916bf809e265ff95f3910c8f2999fb88d697f9b1e8bacf624ee3750a90cdaf38d1777b848659ded147da5669c46b60febe6c5c05e4679
7
+ data.tar.gz: 2fa8a1a3b59f900553eb91673dc5b86daf9e25ad35d45ada3ee0cb8799882a4de9da7a3f5e59e82ebd24570f1eb86cb0813ebea959462fd3248495eb61538f13
@@ -13,26 +13,32 @@ module HQ
13
13
  non_breaking: 2
14
14
  }
15
15
 
16
- class << self
17
- def compare(old_schema, new_schema, criticality: :breaking)
18
- old_schema.load_types! if old_schema < ::GraphQL::Schema
19
- new_schema.load_types! if old_schema < ::GraphQL::Schema
20
- level = CRITICALITY[criticality]
21
- raise ::ArgumentError, "Invalid criticality. Possible values are #{CRITICALITY.keys.join(", ")}" unless level
16
+ def self.compare(old_schema, new_schema, criticality: :breaking)
17
+ level = CRITICALITY[criticality]
18
+ raise ::ArgumentError, "Invalid criticality. Possible values are #{CRITICALITY.keys.join(", ")}" unless level
19
+
20
+ result = ::GraphQL::SchemaComparator.compare(prepare_schema(old_schema), prepare_schema(new_schema))
21
+ return if result.identical?
22
+ changes = {}
23
+ changes[:breaking] = result.breaking_changes
24
+ if level >= CRITICALITY[:dangerous]
25
+ changes[:dangerous] = result.dangerous_changes
26
+ end
27
+ if level >= CRITICALITY[:non_breaking]
28
+ changes[:non_breaking] = result.non_breaking_changes
29
+ end
30
+ return unless changes.values.flatten.any?
22
31
 
23
- result = ::GraphQL::SchemaComparator.compare(old_schema, new_schema)
24
- return nil if result.identical?
25
- changes = {}
26
- changes[:breaking] = result.breaking_changes
27
- if level >= CRITICALITY[:dangerous]
28
- changes[:dangerous] = result.dangerous_changes
29
- end
30
- if level >= CRITICALITY[:non_breaking]
31
- changes[:non_breaking] = result.non_breaking_changes
32
- end
33
- return nil unless changes.values.flatten.any?
32
+ changes
33
+ end
34
+
35
+ class << self
36
+ private
34
37
 
35
- changes
38
+ def prepare_schema(schema)
39
+ schema = ::GraphQL::Schema.from_definition(schema) if schema.is_a?(String)
40
+ schema.load_types!
41
+ schema
36
42
  end
37
43
  end
38
44
  end
@@ -5,8 +5,8 @@ module HQ
5
5
  module Ext
6
6
  module SchemaExtensions
7
7
  def self.prepended(klass)
8
- klass.alias_method :add_type_without_lazyload, :add_type
9
- klass.alias_method :add_type, :add_type_with_lazyload
8
+ klass.alias_method :add_type_and_traverse_without_types, :add_type_and_traverse
9
+ klass.alias_method :add_type_and_traverse, :add_type_and_traverse_with_types
10
10
  end
11
11
 
12
12
  def execute(*args, **options)
@@ -30,17 +30,17 @@ module HQ
30
30
 
31
31
  def load_types!
32
32
  ::HQ::GraphQL.load_types!
33
- return if @add_type_with_lazyload.blank?
34
- while (args, options = @add_type_with_lazyload.shift)
35
- add_type_without_lazyload(*args, **options)
33
+ return if @add_type_and_traverse_with_types.blank?
34
+ while (args, options = @add_type_and_traverse_with_types.shift)
35
+ add_type_and_traverse_without_types(*args, **options)
36
36
  end
37
37
  end
38
38
 
39
39
  # Defer adding types until first schema execution
40
- # https://github.com/rmosolgo/graphql-ruby/blob/792f276444e1dd6004fcafe3820d65fdbbe285f0/lib/graphql/schema.rb#L1888-L1980
41
- def add_type_with_lazyload(*args, **options)
42
- @add_type_with_lazyload ||= []
43
- @add_type_with_lazyload.push([args, options])
40
+ # https://github.com/rmosolgo/graphql-ruby/blob/345ebb2e3833909963067d81e0e8378717b5bdbf/lib/graphql/schema.rb#L1792
41
+ def add_type_and_traverse_with_types(*args, **options)
42
+ @add_type_and_traverse_with_types ||= []
43
+ @add_type_and_traverse_with_types.push([args, options])
44
44
  end
45
45
  end
46
46
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module HQ
4
4
  module GraphQL
5
- VERSION = "2.2.0"
5
+ VERSION = "2.2.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hq-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Jones
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-01 00:00:00.000000000 Z
11
+ date: 2021-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails