graphql-client 0.12.1 → 0.12.2

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
2
  SHA1:
3
- metadata.gz: 943d157f589058bdca038c48549ed4acb09d7ffb
4
- data.tar.gz: 1f8e6364de03008e01506a6a3daf2ad22c74470c
3
+ metadata.gz: 00141a0b18656c8a3134bf9b441598ce97eeb1ae
4
+ data.tar.gz: 749d8bc7f60581177c4c7ea012b6d515180a87e3
5
5
  SHA512:
6
- metadata.gz: a4d339911ca201b26f256c0253b709951d3353a48768d076c9d5bee48dc1deae7d7158e2ae56d5c7d18cd7531c912f406f82d9c62c777792b4f9e15af49fbf0e
7
- data.tar.gz: 34919308f4a441702a8d2c40c888499ad9b1b4abb9f4572425f0e69ad62621e65d87b21b844426a7e81559daa650b513c4df989c8e19cb9d1aad18fa4f3c6f1c
6
+ metadata.gz: ea43f83a968fa438728cb3316f220a4bc58d206b56af5e2dbaee8709b9717ac6e744594e25e69db1bd1250409cdd8021d503e42f287b5dae97fdf70d51c6e37b
7
+ data.tar.gz: 3dbab0f1dfd017a1a97aaff1410cbc9971211cf0d507dd6a9b31f19ede515de638e387fc792d6e2f8a4c613624ee867789b3daec4bff5137b021e515b1f44f5c
@@ -4,7 +4,7 @@ require "graphql/client/error"
4
4
  module GraphQL
5
5
  class Client
6
6
 
7
- # Collcation will not be enforced if a stack trace includes any of these gems.
7
+ # Collocation will not be enforced if a stack trace includes any of these gems.
8
8
  WHITELISTED_GEM_NAMES = %w{pry byebug}
9
9
 
10
10
  # Raised when method is called from outside the expected file scope.
@@ -31,7 +31,7 @@ module GraphQL
31
31
  errors
32
32
  end
33
33
 
34
- # Internal: Initalize from collection of errors.
34
+ # Internal: Initialize from collection of errors.
35
35
  #
36
36
  # errors - Array of GraphQL Hash error objects
37
37
  # path - Array of String|Integer fields to data
@@ -129,7 +129,7 @@ module GraphQL
129
129
  # message.
130
130
  def each
131
131
  return enum_for(:each) unless block_given?
132
- messages.keys.each do |field|
132
+ messages.each_key do |field|
133
133
  messages[field].each { |error| yield field, error }
134
134
  end
135
135
  end
@@ -5,7 +5,7 @@ module GraphQL
5
5
  # Public: Erubi enhancer that adds support for GraphQL static query sections.
6
6
  #
7
7
  # <%graphql
8
- # query GetVerison {
8
+ # query GetVersion {
9
9
  # version
10
10
  # }
11
11
  # %>
@@ -13,7 +13,7 @@ module GraphQL
13
13
  # query sections.
14
14
  #
15
15
  # <%graphql
16
- # query GetVerison {
16
+ # query GetVersion {
17
17
  # version
18
18
  # }
19
19
  # %>
@@ -5,7 +5,7 @@ module GraphQL
5
5
  # Public: Erubis enhancer that adds support for GraphQL static query sections.
6
6
  #
7
7
  # <%graphql
8
- # query GetVerison {
8
+ # query GetVersion {
9
9
  # version
10
10
  # }
11
11
  # %>
@@ -16,7 +16,7 @@ module GraphQL
16
16
  @hash = hash
17
17
  @aliases = {}
18
18
 
19
- hash.keys.each do |key|
19
+ hash.each_key do |key|
20
20
  if key.is_a?(String)
21
21
  key_alias = ActiveSupport::Inflector.underscore(key)
22
22
  @aliases[key_alias] = key if key != key_alias
@@ -43,6 +43,10 @@ module GraphQL
43
43
  alias has_key? key?
44
44
  alias member? key?
45
45
 
46
+ def each_key(&block)
47
+ @hash.each_key { |key| yield convert_value(key) }
48
+ end
49
+
46
50
  private
47
51
 
48
52
  def convert_value(key)
@@ -22,7 +22,7 @@ module GraphQL
22
22
  when GraphQL::ListType
23
23
  define_class(definition, irep_node, type.of_type).to_list_type
24
24
  else
25
- const_get(type.name).define_class(definition, irep_node)
25
+ get_class(type.name).define_class(definition, irep_node)
26
26
  end
27
27
 
28
28
  irep_node.ast_node.directives.inject(type_klass) do |klass, directive|
@@ -33,6 +33,28 @@ module GraphQL
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ def get_class(type_name)
38
+ const_get(normalize_type_name(type_name))
39
+ end
40
+
41
+ def set_class(type_name, klass)
42
+ class_name = normalize_type_name(type_name)
43
+
44
+ if constants.include?(class_name.to_sym)
45
+ raise ArgumentError,
46
+ "Can't define #{class_name} to represent type #{type_name} " \
47
+ "because it's already defined"
48
+ end
49
+
50
+ const_set(class_name, klass)
51
+ end
52
+
53
+ private
54
+
55
+ def normalize_type_name(type_name)
56
+ type_name =~ /\A[A-Z]/ ? type_name : type_name.camelize
57
+ end
36
58
  end
37
59
 
38
60
  def self.generate(schema)
@@ -48,7 +70,7 @@ module GraphQL
48
70
  next if name.start_with?("__")
49
71
  if klass = class_for(schema, type, cache)
50
72
  klass.schema_module = mod
51
- mod.const_set(name, klass)
73
+ mod.set_class(name, klass)
52
74
  end
53
75
  end
54
76
 
@@ -22,7 +22,7 @@ module GraphQL
22
22
 
23
23
  def define_class(definition, irep_node)
24
24
  new(irep_node.typed_children.keys.map { |ctype|
25
- schema_module.const_get(ctype.name).define_class(definition, irep_node)
25
+ schema_module.get_class(ctype.name).define_class(definition, irep_node)
26
26
  })
27
27
  end
28
28
  end
@@ -22,7 +22,7 @@ module GraphQL
22
22
 
23
23
  def define_class(definition, irep_node)
24
24
  new(irep_node.typed_children.keys.map { |ctype|
25
- schema_module.const_get(ctype.name).define_class(definition, irep_node)
25
+ schema_module.get_class(ctype.name).define_class(definition, irep_node)
26
26
  })
27
27
  end
28
28
  end
@@ -19,11 +19,11 @@ module RuboCop
19
19
  return unless node.location.expression.source =~ /^<<(-|~)?GRAPHQL/
20
20
 
21
21
  node.each_child_node(:begin) do |begin_node|
22
- add_offense(begin_node, :expression, "Do not interpolate variables into GraphQL queries, " \
22
+ add_offense(begin_node, location: :expression, message: "Do not interpolate variables into GraphQL queries, " \
23
23
  "used variables instead.")
24
24
  end
25
25
 
26
- add_offense(node, :expression, "GraphQL heredocs should be quoted. <<-'GRAPHQL'")
26
+ add_offense(node, location: :expression, message: "GraphQL heredocs should be quoted. <<-'GRAPHQL'")
27
27
  end
28
28
 
29
29
  def autocorrect(node)
@@ -44,7 +44,7 @@ module RuboCop
44
44
 
45
45
  fields.each do |field, count|
46
46
  next if count > 0
47
- add_offense(nil, ranges[field], "GraphQL field '#{field}' query but was not used in template.")
47
+ add_offense(nil, location: ranges[field], message: "GraphQL field '#{field}' query but was not used in template.")
48
48
  end
49
49
  end
50
50
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-31 00:00:00.000000000 Z
11
+ date: 2017-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -126,28 +126,28 @@ dependencies:
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '0.3'
129
+ version: '0.6'
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '0.3'
136
+ version: '0.6'
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: rubocop
139
139
  requirement: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: '0.47'
143
+ version: '0.49'
144
144
  type: :development
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: '0.47'
150
+ version: '0.49'
151
151
  description: A Ruby library for declaring, composing and executing GraphQL queries
152
152
  email: engineering@github.com
153
153
  executables: []
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  version: '0'
212
212
  requirements: []
213
213
  rubyforge_project:
214
- rubygems_version: 2.6.11
214
+ rubygems_version: 2.6.12
215
215
  signing_key:
216
216
  specification_version: 4
217
217
  summary: GraphQL Client