hq-graphql 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/hq/graphql.rb +1 -1
- data/lib/hq/graphql/comparator.rb +50 -0
- data/lib/hq/graphql/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29c063cc8a29b6e30df91f11f8ed83bcaebee761fff76630bc2b2e80af9781d2
|
4
|
+
data.tar.gz: cb3e76b3c272ee517fd9de9b71c65695b5379e8cd3f2a2b412edb85419b12fe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 992f59fa59af5c4d3d06a5902a85dde3a1839c881ac25fa15586ff8a92d15e4cde75192159a9ec0e939c286c99a2e83a2390203b84bf3de0c151bbf796945213
|
7
|
+
data.tar.gz: 242640df93c46a0a1d8f1af7851bf659901b896ae8c5f2e4088ece50909fdd31ea81cd20c6809a5e24f2c965b36db74bfdcb081c18ef698b062f3fb14ad54038
|
data/lib/hq/graphql.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "graphql/schema_comparator"
|
5
|
+
|
6
|
+
module HQ
|
7
|
+
module GraphQL
|
8
|
+
class Comparator
|
9
|
+
# Higher values will include changes from criticalities with lower values as well.
|
10
|
+
# For example, setting the criticality as dangerous will return dangerous and breaking changes.
|
11
|
+
CRITICALITY = {
|
12
|
+
breaking: 0,
|
13
|
+
dangerous: 1,
|
14
|
+
non_breaking: 2
|
15
|
+
}
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def compare(old_schema, new_schema, criticality: :breaking)
|
19
|
+
level = CRITICALITY[criticality]
|
20
|
+
raise ::ArgumentError, "Invalid criticality. Possible values are #{CRITICALITY.keys.join(", ")}" unless level
|
21
|
+
|
22
|
+
result = ::GraphQL::SchemaComparator.compare(convert_schema_to_string(old_schema), convert_schema_to_string(new_schema))
|
23
|
+
return nil if result.identical?
|
24
|
+
|
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
|
+
|
34
|
+
changes
|
35
|
+
end
|
36
|
+
|
37
|
+
def dump_schema_to_file(directory:, filename:, schema:)
|
38
|
+
::FileUtils.mkdir_p(directory)
|
39
|
+
::File.open(::File.join(directory, filename), "w") { |file| file.write(schema.to_definition) }
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def convert_schema_to_string(schema)
|
45
|
+
schema.is_a?(::String) ? schema : schema.to_definition
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
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.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -58,6 +58,20 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0.4'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: graphql-schema_comparator
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.6'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0.6'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
76
|
name: pg
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -267,6 +281,7 @@ files:
|
|
267
281
|
- lib/hq-graphql.rb
|
268
282
|
- lib/hq/graphql.rb
|
269
283
|
- lib/hq/graphql/active_record_extensions.rb
|
284
|
+
- lib/hq/graphql/comparator.rb
|
270
285
|
- lib/hq/graphql/config.rb
|
271
286
|
- lib/hq/graphql/engine.rb
|
272
287
|
- lib/hq/graphql/field.rb
|