graphql_schema 0.1.2 → 0.1.7

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: 2a67ab3552d63acea7c540bb23302da480ceb086
4
- data.tar.gz: 15ba4260e9dac2a749d707e58b4ef8b9f2f2e0fa
2
+ SHA256:
3
+ metadata.gz: 6bb27ea8446623bec1c7ab56efe9255026f0b9038d75197c171da7420daf3d0a
4
+ data.tar.gz: d2fc1659a41b311cc8aa40f576b7f0a429fd7c16f2d2dadd43526d4e0457a64a
5
5
  SHA512:
6
- metadata.gz: 6ec16d95a0cc092b7278cce9ae7035ed010b79bcf92e5581746268a0266c52df96af3cc7427b9dbbcc6c4c94f6224edd3fca027194b9705b6ee6d0e94db39c32
7
- data.tar.gz: 41f91462ce0defc16a40f1c6df344d54e781bbb177cbcaa0af64ba5a47c6bb14fb52d5b1ec3a48e15eda01cf087960aa2bb59aea3638df9684687d6379b22b29
6
+ metadata.gz: aacedad3fabab90e55d4023c43e026b783f8176059deb21408fb6555d76a8b10a956d03a2398f02ea094a0fd34466fcebe20f5d0d38e2c184e0effecd076fa98
7
+ data.tar.gz: da7e757dd0fdf7236fa8380127ec4f1d418fc59a66e9438cca9fb09d3a52b6110804513f51bd9d7039440b750a197b0a892e92b255b0f9811dbc2628f5cbc47c
@@ -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,26 @@ 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
+ end
42
+
27
43
  module NamedHash
28
44
  def name
29
45
  @hash.fetch('name')
@@ -49,6 +65,10 @@ class GraphQLSchema
49
65
  @hash.fetch('description')
50
66
  end
51
67
 
68
+ def to_h
69
+ @hash
70
+ end
71
+
52
72
  private
53
73
 
54
74
  def split_name
@@ -85,15 +105,12 @@ class GraphQLSchema
85
105
  class Field
86
106
  include NamedHash
87
107
  include Deprecatable
108
+ include WithArgs
88
109
 
89
110
  def initialize(field_hash)
90
111
  @hash = field_hash
91
112
  end
92
113
 
93
- def args
94
- @args ||= @hash.fetch('args').map{ |arg_hash| InputValue.new(arg_hash) }
95
- end
96
-
97
114
  def required_args
98
115
  @required_args ||= args.select{ |arg| arg.type.non_null? }
99
116
  end
@@ -171,6 +188,10 @@ class GraphQLSchema
171
188
  @of_type ||= TypeDeclaration.new(@hash.fetch('ofType'))
172
189
  end
173
190
 
191
+ def list?
192
+ kind == 'LIST'
193
+ end
194
+
174
195
  def non_null?
175
196
  kind == 'NON_NULL'
176
197
  end
@@ -184,6 +205,10 @@ class GraphQLSchema
184
205
  end
185
206
  end
186
207
 
208
+ def unwrap_list
209
+ list? ? of_type.unwrap_list : self
210
+ end
211
+
187
212
  def unwrap_non_null
188
213
  non_null? ? of_type.unwrap_non_null : self
189
214
  end
@@ -198,12 +223,36 @@ class GraphQLSchema
198
223
  end
199
224
  end
200
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
+
201
245
  class TypeDefinition < Type
202
246
  def fields(include_deprecated: false)
247
+ return unless @hash.fetch('fields')
203
248
  @fields ||= @hash.fetch('fields').map{ |field_hash| Field.new(field_hash) }
204
249
  include_deprecated ? @fields : @fields.reject(&:deprecated?)
205
250
  end
206
251
 
252
+ def fields_by_name
253
+ @fields_by_name ||= fields(include_deprecated: true).map{ |field| [field.name, field]}.to_h
254
+ end
255
+
207
256
  def input_fields
208
257
  @input_fields ||= @hash.fetch('inputFields').map{ |field_hash| InputValue.new(field_hash) }
209
258
  end
@@ -1,3 +1,3 @@
1
1
  class GraphQLSchema
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.7"
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.2
4
+ version: 0.1.7
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-07 00:00:00.000000000 Z
11
+ date: 2021-05-18 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