graphql-schema_comparator 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ module GraphQL
2
+ module SchemaComparator
3
+ module Diff
4
+ class Union
5
+ def initialize(old_type, new_type)
6
+ @old_type = old_type
7
+ @new_type = new_type
8
+
9
+ @old_possible_types = old_type.possible_types
10
+ @new_possible_types = new_type.possible_types
11
+ end
12
+
13
+ def diff
14
+ changes = []
15
+ changes += removed_possible_types.map do |removed|
16
+ Changes::UnionMemberRemoved.new(new_type, removed)
17
+ end
18
+ changes += added_possible_types.map do |added|
19
+ Changes::UnionMemberAdded.new(new_type, added)
20
+ end
21
+ changes
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :old_type, :new_type, :old_possible_types, :new_possible_types
27
+
28
+ def removed_possible_types
29
+ old_possible_types.select { |type| !new_possible_types.include?(type) }
30
+ end
31
+
32
+ def added_possible_types
33
+ new_possible_types.select { |type| !old_possible_types.include?(type) }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,23 @@
1
+ module GraphQL
2
+ module SchemaComparator
3
+ class Result
4
+ attr_reader :changes
5
+
6
+ def initialize(changes)
7
+ @changes = changes
8
+ end
9
+
10
+ def identical?
11
+ @changes.empty?
12
+ end
13
+
14
+ def breaking_changes
15
+ @changes.select { |c| c.breaking }
16
+ end
17
+
18
+ def breaking?
19
+ @changes.any? { |c| c.breaking }
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module GraphQL
2
+ module SchemaComparator
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
data/schema.graphql ADDED
@@ -0,0 +1 @@
1
+ schema { query: Query } type Query { a: String }
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: graphql-schema_comparator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Marc-Andre Giroux
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: graphql
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.19'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.19'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: GraphQL::SchemaComparator compares two GraphQL schemas given their IDL
98
+ and returns a list of changes.
99
+ email:
100
+ - mgiroux0@gmail.com
101
+ executables:
102
+ - graphql-schema
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/graphql-schema
114
+ - bin/setup
115
+ - graphql-schema_comparator.gemspec
116
+ - lib/graphql/schema_comparator.rb
117
+ - lib/graphql/schema_comparator/changes.rb
118
+ - lib/graphql/schema_comparator/diff/argument.rb
119
+ - lib/graphql/schema_comparator/diff/enum.rb
120
+ - lib/graphql/schema_comparator/diff/field.rb
121
+ - lib/graphql/schema_comparator/diff/input_field.rb
122
+ - lib/graphql/schema_comparator/diff/input_object.rb
123
+ - lib/graphql/schema_comparator/diff/interface.rb
124
+ - lib/graphql/schema_comparator/diff/object_type.rb
125
+ - lib/graphql/schema_comparator/diff/schema.rb
126
+ - lib/graphql/schema_comparator/diff/union.rb
127
+ - lib/graphql/schema_comparator/result.rb
128
+ - lib/graphql/schema_comparator/version.rb
129
+ - schema.graphql
130
+ homepage: http://mgiroux.me
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.5.1
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Compare GraphQL schemas and get the changes that happened.
154
+ test_files: []