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 +4 -4
- data/lib/hq/graphql/comparator.rb +24 -18
- data/lib/hq/graphql/ext/schema_extensions.rb +9 -9
- data/lib/hq/graphql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08dfdf7baf4c44a54bdb3ecb9e0e89baacfaab9e6dda53525a0f8dded456a8c9'
|
4
|
+
data.tar.gz: 2b12d46d565e00710f49618e603c6a88f7fd09cc753d82cb8395b8e2d7f36447
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
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 :
|
9
|
-
klass.alias_method :
|
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 @
|
34
|
-
while (args, options = @
|
35
|
-
|
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/
|
41
|
-
def
|
42
|
-
@
|
43
|
-
@
|
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
|
data/lib/hq/graphql/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|