graphql-client 0.2.3 → 0.2.4
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 +7 -1
- data/lib/rubocop/cop/graphql/heredoc.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94402332ad2601ad1ce9b92053ab77537d98a252
|
4
|
+
data.tar.gz: 0bf48ac46855de0b767809bb76979f04f1ffaad8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1af4235ed60323283e74f9491029f48e93933a63e864249bef829e1b3f8d0727537105f4a55a2b4783c6bfea01b3a18de28d76355d2d97d2b6e254448714ecd7
|
7
|
+
data.tar.gz: 4cbd9d20bf35164d6979a4137bd7b54a58d175132c9536465c57a34c64ed1141bc80602f1aad5f647bd2bd06119c80ae6803253eb523a1d448fa5e3eb71fa6e5
|
data/lib/graphql/client.rb
CHANGED
@@ -16,6 +16,8 @@ module GraphQL
|
|
16
16
|
# to point at a remote GraphQL HTTP service or execute directly against a
|
17
17
|
# Schema object.
|
18
18
|
class Client
|
19
|
+
class DynamicQueryError < Error; end
|
20
|
+
class NotImplementedError < Error; end
|
19
21
|
class ValidationError < Error; end
|
20
22
|
|
21
23
|
attr_reader :schema, :execute
|
@@ -244,12 +246,16 @@ module GraphQL
|
|
244
246
|
attr_reader :document
|
245
247
|
|
246
248
|
def query(definition, variables: {}, context: {})
|
247
|
-
raise
|
249
|
+
raise NotImplementedError, "client network execution not configured" unless execute
|
248
250
|
|
249
251
|
unless definition.is_a?(OperationDefinition)
|
250
252
|
raise TypeError, "expected definition to be a #{OperationDefinition.name} but was #{document.class.name}"
|
251
253
|
end
|
252
254
|
|
255
|
+
unless definition.name
|
256
|
+
raise DynamicQueryError, "expected definition to be assigned to a static constant https://git.io/vXXSE"
|
257
|
+
end
|
258
|
+
|
253
259
|
variables = deep_stringify_keys(variables)
|
254
260
|
|
255
261
|
document = definition.document
|
@@ -5,12 +5,26 @@ module RuboCop
|
|
5
5
|
module GraphQL
|
6
6
|
# Public: Cop for enforcing non-interpolated GRAPHQL heredocs.
|
7
7
|
class Heredoc < Cop
|
8
|
+
def on_dstr(node)
|
9
|
+
check_str(node)
|
10
|
+
end
|
11
|
+
|
8
12
|
def on_str(node)
|
13
|
+
check_str(node)
|
14
|
+
end
|
15
|
+
|
16
|
+
def check_str(node)
|
9
17
|
return unless node.location.is_a?(Parser::Source::Map::Heredoc)
|
10
18
|
return unless node.location.expression.source == "<<-GRAPHQL"
|
11
19
|
|
12
20
|
add_offense(node, :expression, "GraphQL heredocs should be quoted. <<-'GRAPHQL'")
|
13
21
|
end
|
22
|
+
|
23
|
+
def autocorrect(node)
|
24
|
+
->(corrector) do
|
25
|
+
corrector.replace(node.location.expression, "<<-'GRAPHQL'")
|
26
|
+
end
|
27
|
+
end
|
14
28
|
end
|
15
29
|
end
|
16
30
|
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.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|