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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1b53518026d7968c05ec71fa638138a4bd72789
4
- data.tar.gz: 0b0a919fc6d6e55620a037f07e0ea9cb97c4d04a
3
+ metadata.gz: 94402332ad2601ad1ce9b92053ab77537d98a252
4
+ data.tar.gz: 0bf48ac46855de0b767809bb76979f04f1ffaad8
5
5
  SHA512:
6
- metadata.gz: ef060d80791c85c066ff96d4ceb414f2dda20d3be777d4c225698012941a073e1085d1c26aa6b63534ad709e8400d95f204c95d5c8b862737904a74c5c0a8b8a
7
- data.tar.gz: b92fea6950ee7f6faae22398c08e8d7fc0b9ff79ba262d884e1381c21a5c36a82fa8355c344d9460bbae390c6e837c1ab11f687bef5ce8bef3e7912c0586a70c
6
+ metadata.gz: 1af4235ed60323283e74f9491029f48e93933a63e864249bef829e1b3f8d0727537105f4a55a2b4783c6bfea01b3a18de28d76355d2d97d2b6e254448714ecd7
7
+ data.tar.gz: 4cbd9d20bf35164d6979a4137bd7b54a58d175132c9536465c57a34c64ed1141bc80602f1aad5f647bd2bd06119c80ae6803253eb523a1d448fa5e3eb71fa6e5
@@ -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 Error, "client network execution not configured" unless execute
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.3
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-01 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport