graphql-client 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/client.rb +8 -5
- data/lib/graphql/client/query_result.rb +23 -1
- data/lib/rubocop/cop/graphql/heredoc.rb +6 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 665795b2cb201c59918533b567ea75e1d9e17c8c
|
4
|
+
data.tar.gz: 6c0aa59a2fb36248cefa5777a986afb9a3e56ca5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3462c80267b7dd02fbaa07a5386187a285f6b4c7ebff7a122f961c59d9ecc9b6d16e0a5b1d25b37236051265552d7b5b89a10984cf45e8fbf7a8f2c054f5b79c
|
7
|
+
data.tar.gz: b8b8d763e2d13f62ffb24ce53a82882a58517abe61179b5aa509a3263a7366377d305da7fdbb057430a248284a6675c48ee39fab61d4872ae6be1245a7dbb874
|
data/lib/graphql/client.rb
CHANGED
@@ -210,11 +210,14 @@ module GraphQL
|
|
210
210
|
definition_dependencies.merge(fragment.document.definitions)
|
211
211
|
"...#{fragment.definition_name}"
|
212
212
|
else
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
213
|
+
if fragment
|
214
|
+
message = "expected #{const_name} to be a #{FragmentDefinition}, but was a #{fragment.class}."
|
215
|
+
if fragment.is_a?(Module) && fragment.constants.any?
|
216
|
+
message += " Did you mean #{fragment}::#{fragment.constants.first}?"
|
217
|
+
end
|
218
|
+
else
|
219
|
+
message = "uninitialized constant #{const_name}"
|
220
|
+
end
|
218
221
|
|
219
222
|
error = ValidationError.new(message)
|
220
223
|
error.set_backtrace(["#{filename}:#{lineno + match.pre_match.count("\n") + 1}"] + caller)
|
@@ -14,6 +14,11 @@ module GraphQL
|
|
14
14
|
#
|
15
15
|
# Wrappers also limit field visibility to fragment definitions.
|
16
16
|
class QueryResult
|
17
|
+
class NoFieldError < Error; end
|
18
|
+
class ImplicitlyFetchedFieldError < NoFieldError; end
|
19
|
+
class UnfetchedFieldError < NoFieldError; end
|
20
|
+
class UnimplementedFieldError < NoFieldError; end
|
21
|
+
|
17
22
|
# Internal: Get QueryResult class for result of query.
|
18
23
|
#
|
19
24
|
# Returns subclass of QueryResult or nil.
|
@@ -248,7 +253,24 @@ module GraphQL
|
|
248
253
|
def method_missing(*args)
|
249
254
|
super
|
250
255
|
rescue NoMethodError => e
|
251
|
-
|
256
|
+
type = self.class.type
|
257
|
+
raise e unless type
|
258
|
+
|
259
|
+
unless type.fields[e.name.to_s]
|
260
|
+
raise UnimplementedFieldError, "undefined field `#{e.name}' on #{type} type. https://git.io/v1y3m"
|
261
|
+
end
|
262
|
+
|
263
|
+
if data[e.name.to_s]
|
264
|
+
error_class = ImplicitlyFetchedFieldError
|
265
|
+
message = "implicitly fetched field `#{e.name}' on #{type} type. https://git.io/v1yGL"
|
266
|
+
else
|
267
|
+
error_class = UnfetchedFieldError
|
268
|
+
message = "unfetched field `#{e.name}' on #{type} type. https://git.io/v1y3U"
|
269
|
+
end
|
270
|
+
|
271
|
+
node = self.class.source_node
|
272
|
+
message += "\n\n" + node.to_query_string.sub(/\}$/, "+ #{e.name}\n}") if node
|
273
|
+
raise error_class, message
|
252
274
|
end
|
253
275
|
|
254
276
|
def respond_to_missing?(*args)
|
@@ -16,7 +16,12 @@ module RuboCop
|
|
16
16
|
|
17
17
|
def check_str(node)
|
18
18
|
return unless node.location.is_a?(Parser::Source::Map::Heredoc)
|
19
|
-
return unless node.location.expression.source
|
19
|
+
return unless node.location.expression.source =~ /^<<(-|~)?GRAPHQL/
|
20
|
+
|
21
|
+
node.each_child_node(:begin) do |begin_node|
|
22
|
+
add_offense(begin_node, :expression, "Do not interpolate variables into GraphQL queries, " \
|
23
|
+
"used variables instead.")
|
24
|
+
end
|
20
25
|
|
21
26
|
add_offense(node, :expression, "GraphQL heredocs should be quoted. <<-'GRAPHQL'")
|
22
27
|
end
|
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.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -92,6 +92,20 @@ dependencies:
|
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '11.2'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rubocop-github
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0.2'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0.2'
|
95
109
|
- !ruby/object:Gem::Dependency
|
96
110
|
name: rubocop
|
97
111
|
requirement: !ruby/object:Gem::Requirement
|