graphql_schema 0.1.3 → 0.1.8

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
- SHA1:
3
- metadata.gz: 5bfa3a0670d8de22e60d7c06fd082ab9f3f8ee5f
4
- data.tar.gz: 288dc6465191002e3e0d30add5f85b23442cd586
2
+ SHA256:
3
+ metadata.gz: 97547e740c444ed9e293f4031694a757954b1f5cabf10d45e1e9556fc189703e
4
+ data.tar.gz: 41ac5410e992209a7ed3be88c3065c8df7846763242c214bd8cb2b5bcfdab4c9
5
5
  SHA512:
6
- metadata.gz: 0d1565d897649f8e67fbcb99fc63c94e886259f0f6ee063cba7b12e2b26e45fcc3dd86a983c479ab483de7d67e7f09ad9279ab658a27f5ed5d9c3827cf210273
7
- data.tar.gz: 732f8f6c18a8fa4767d1379956b956c7e9510725de1d722254d3d5e858aca33e056d61171cf4662a66340f78f0fe5c21c5ee551d9117529fe5e033b53d6eece6
6
+ metadata.gz: b385a964e26cd64164013105f656134ac1e75328a3c4ed3fe9766506207ea68e983907c8cf4f72ec6cab09ec926eee61c4e9ef047bab279ee68ccdda7e873d35
7
+ data.tar.gz: cd5e3fd60261be4036845dfd936b8b7654c0e84c06ad51183cf9d4633dfa4d775a8663e7c546e1234777a8c6c0752f59d64bdf0ae5d1f627be5a7a75b370286c
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.bindir = "exe"
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
22
23
 
23
24
  spec.add_development_dependency "graphql", "~> 1.2"
24
25
  spec.add_development_dependency "byebug", '~> 9.0' if RUBY_ENGINE == 'ruby'
25
- spec.add_development_dependency "bundler", "~> 1.12"
26
26
  spec.add_development_dependency "rake", "~> 10.0"
27
27
  spec.add_development_dependency "minitest", "~> 5.0"
28
28
  end
@@ -20,10 +20,34 @@ class GraphQLSchema
20
20
  end
21
21
  end
22
22
 
23
+ def directives
24
+ @directives ||= @hash.fetch('directives').map do |directive|
25
+ Directive.new(directive)
26
+ end.sort_by(&:name)
27
+ end
28
+
23
29
  def types
24
30
  @types ||= @hash.fetch('types').map{ |type_hash| TypeDefinition.new(type_hash) }.sort_by(&:name)
25
31
  end
26
32
 
33
+ def types_by_name
34
+ @types_by_name ||= types.map { |type| [type.name, type] }.to_h
35
+ end
36
+
37
+ module WithArgs
38
+ def args
39
+ @args ||= @hash.fetch('args').map{ |arg_hash| InputValue.new(arg_hash) }
40
+ end
41
+
42
+ def required_args
43
+ @required_args ||= args.select{ |arg| arg.type.non_null? }
44
+ end
45
+
46
+ def optional_args
47
+ @optional_args ||= args.reject{ |arg| arg.type.non_null? }
48
+ end
49
+ end
50
+
27
51
  module NamedHash
28
52
  def name
29
53
  @hash.fetch('name')
@@ -89,23 +113,12 @@ class GraphQLSchema
89
113
  class Field
90
114
  include NamedHash
91
115
  include Deprecatable
116
+ include WithArgs
92
117
 
93
118
  def initialize(field_hash)
94
119
  @hash = field_hash
95
120
  end
96
121
 
97
- def args
98
- @args ||= @hash.fetch('args').map{ |arg_hash| InputValue.new(arg_hash) }
99
- end
100
-
101
- def required_args
102
- @required_args ||= args.select{ |arg| arg.type.non_null? }
103
- end
104
-
105
- def optional_args
106
- @optional_args ||= args.reject{ |arg| arg.type.non_null? }
107
- end
108
-
109
122
  def type
110
123
  @type ||= TypeDeclaration.new(@hash.fetch('type'))
111
124
  end
@@ -175,6 +188,10 @@ class GraphQLSchema
175
188
  @of_type ||= TypeDeclaration.new(@hash.fetch('ofType'))
176
189
  end
177
190
 
191
+ def list?
192
+ kind == 'LIST'
193
+ end
194
+
178
195
  def non_null?
179
196
  kind == 'NON_NULL'
180
197
  end
@@ -188,6 +205,10 @@ class GraphQLSchema
188
205
  end
189
206
  end
190
207
 
208
+ def unwrap_list
209
+ list? ? of_type.unwrap_list : self
210
+ end
211
+
191
212
  def unwrap_non_null
192
213
  non_null? ? of_type.unwrap_non_null : self
193
214
  end
@@ -202,6 +223,25 @@ class GraphQLSchema
202
223
  end
203
224
  end
204
225
 
226
+ class Directive
227
+ include NamedHash
228
+ include WithArgs
229
+
230
+ BUILTIN = %w(skip include deprecated).to_set
231
+
232
+ def initialize(directive)
233
+ @hash = directive
234
+ end
235
+
236
+ def locations
237
+ @hash.fetch('locations')
238
+ end
239
+
240
+ def builtin?
241
+ BUILTIN.include?(name)
242
+ end
243
+ end
244
+
205
245
  class TypeDefinition < Type
206
246
  def fields(include_deprecated: false)
207
247
  return unless @hash.fetch('fields')
@@ -209,8 +249,12 @@ class GraphQLSchema
209
249
  include_deprecated ? @fields : @fields.reject(&:deprecated?)
210
250
  end
211
251
 
252
+ def fields_by_name
253
+ @fields_by_name ||= fields(include_deprecated: true).map{ |field| [field.name, field]}.to_h
254
+ end
255
+
212
256
  def input_fields
213
- @input_fields ||= @hash.fetch('inputFields').map{ |field_hash| InputValue.new(field_hash) }.sort_by(&:name)
257
+ @input_fields ||= @hash.fetch('inputFields').map{ |field_hash| InputValue.new(field_hash) }
214
258
  end
215
259
 
216
260
  def required_input_fields
@@ -1,3 +1,3 @@
1
1
  class GraphQLSchema
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Thacker-Smith
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-09 00:00:00.000000000 Z
11
+ date: 2021-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '9.0'
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.12'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.12'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -102,7 +88,8 @@ files:
102
88
  homepage: https://github.com/Shopify/graphql_schema
103
89
  licenses:
104
90
  - MIT
105
- metadata: {}
91
+ metadata:
92
+ allowed_push_host: https://rubygems.org
106
93
  post_install_message:
107
94
  rdoc_options: []
108
95
  require_paths:
@@ -118,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
105
  - !ruby/object:Gem::Version
119
106
  version: '0'
120
107
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.5.2
108
+ rubygems_version: 3.2.17
123
109
  signing_key:
124
110
  specification_version: 4
125
111
  summary: Classes for convenient use of GraphQL introspection result