graphql 0.19.1 → 0.19.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: 7858558a3c50740243e5bf0c4947bf63b05e2fee
4
- data.tar.gz: a338af05768f34122b1b2d7e9579aa2ced8ee27c
3
+ metadata.gz: c2492431f6efd112dd3a4aa0c2b26e17f2e45df2
4
+ data.tar.gz: cd351bd76f0bf2bf4e173c900710b317210767b7
5
5
  SHA512:
6
- metadata.gz: 43d57c6c30c0cdd5dbc2991c7ebe6fe3fd13d894d3a4ac7d0a53b2a982ffb2567a50d6da46a7dc7ac02e75383e4939184bf12335343671683767002a993f0bcd
7
- data.tar.gz: c24a60479ef04db9373cc4ee8a1659434c3cf26b31656fa133212924487580d387aae6bed9826ca003ac9e43ceac4c864ba5c837944c93d4d5fb976ab6a7c8d0
6
+ metadata.gz: 3faf8b928d7cec65474d15cc3f29dd886f25f23d5b514d9427c578619e6c4ef8fbca048839f7633ad12ad61fae427bab5fe4eb0ff259afb8363b49524b063636
7
+ data.tar.gz: a7574edfbda2742ef46ce2bb70faf5d7f437aced4180f87b2c8c7b55f5a1e267608416ca70864187debe00efac594ece5b705fdfff9edf6b3b7be34875b40b3b
@@ -15,17 +15,8 @@ module GraphQL
15
15
 
16
16
  def result
17
17
  result_name = irep_node.name
18
- begin
19
- raw_value = get_raw_value
20
- { result_name => get_finished_value(raw_value) }
21
- rescue GraphQL::InvalidNullError => err
22
- if field.type.kind.non_null?
23
- raise(err)
24
- else
25
- err.parent_error? || execution_context.add_error(err)
26
- {result_name => nil}
27
- end
28
- end
18
+ raw_value = get_raw_value
19
+ { result_name => get_finished_value(raw_value) }
29
20
  end
30
21
 
31
22
  private
@@ -33,15 +24,34 @@ module GraphQL
33
24
  # After getting the value from the field's resolve method,
34
25
  # continue by "finishing" the value, eg. executing sub-fields or coercing values
35
26
  def get_finished_value(raw_value)
36
- if raw_value.is_a?(GraphQL::ExecutionError)
27
+ case raw_value
28
+ when GraphQL::ExecutionError
37
29
  raw_value.ast_node = irep_node.ast_node
38
30
  raw_value.path = irep_node.path
39
31
  execution_context.add_error(raw_value)
32
+ when Array
33
+ list_errors = raw_value.each_with_index.select { |value, _| value.is_a?(GraphQL::ExecutionError) }
34
+ if list_errors.any?
35
+ list_errors.each do |error, index|
36
+ error.ast_node = irep_node.ast_node
37
+ error.path = irep_node.path + [index]
38
+ execution_context.add_error(error)
39
+ end
40
+ end
40
41
  end
41
42
 
42
43
  strategy_class = GraphQL::Query::SerialExecution::ValueResolution.get_strategy_for_kind(field.type.kind)
43
44
  result_strategy = strategy_class.new(raw_value, field.type, target, parent_type, irep_node, execution_context)
44
- result_strategy.result
45
+ begin
46
+ result_strategy.result
47
+ rescue GraphQL::InvalidNullError => err
48
+ if field.type.kind.non_null?
49
+ raise(err)
50
+ else
51
+ err.parent_error? || execution_context.add_error(err)
52
+ nil
53
+ end
54
+ end
45
55
  end
46
56
 
47
57
 
@@ -111,7 +111,7 @@ module GraphQL
111
111
  when ScalarType, ID_TYPE, STRING_TYPE
112
112
  value.to_s.inspect
113
113
  when EnumType
114
- value.to_s
114
+ type.coerce_result(value)
115
115
  when InputObjectType
116
116
  fields = value.to_h.map{ |field_name, field_value|
117
117
  field_type = type.input_fields.fetch(field_name.to_s).type
@@ -1,3 +1,3 @@
1
1
  module GraphQL
2
- VERSION = "0.19.1"
2
+ VERSION = "0.19.2"
3
3
  end
@@ -27,6 +27,9 @@ describe GraphQL::ExecutionError do
27
27
  executionError
28
28
  }
29
29
  }
30
+ dairyErrors: allDairy(executionErrorAtIndex: 1) {
31
+ __typename
32
+ }
30
33
  dairy {
31
34
  milks {
32
35
  source
@@ -66,6 +69,12 @@ describe GraphQL::ExecutionError do
66
69
  { "flavor" => "Manchego" },
67
70
  { "source" => "COW", "executionError" => nil }
68
71
  ],
72
+ "dairyErrors" => [
73
+ { "__typename" => "Cheese" },
74
+ nil,
75
+ { "__typename" => "Cheese" },
76
+ { "__typename" => "Milk" }
77
+ ],
69
78
  "dairy" => {
70
79
  "milks" => [
71
80
  {
@@ -98,19 +107,24 @@ describe GraphQL::ExecutionError do
98
107
  "locations"=>[{"line"=>22, "column"=>11}],
99
108
  "path"=>["allDairy", 3, "executionError"]
100
109
  },
110
+ {
111
+ "message"=>"missing dairy",
112
+ "locations"=>[{"line"=>25, "column"=>7}],
113
+ "path"=>["dairyErrors", 1]
114
+ },
101
115
  {
102
116
  "message"=>"There was an execution error",
103
- "locations"=>[{"line"=>28, "column"=>11}],
117
+ "locations"=>[{"line"=>31, "column"=>11}],
104
118
  "path"=>["dairy", "milks", 0, "executionError"]
105
119
  },
106
120
  {
107
121
  "message"=>"There was an execution error",
108
- "locations"=>[{"line"=>33, "column"=>15}],
122
+ "locations"=>[{"line"=>36, "column"=>15}],
109
123
  "path"=>["dairy", "milks", 0, "allDairy", 3, "executionError"]
110
124
  },
111
125
  {
112
126
  "message"=>"There was an execution error",
113
- "locations"=>[{"line"=>38, "column"=>7}],
127
+ "locations"=>[{"line"=>41, "column"=>7}],
114
128
  "path"=>["executionError"]
115
129
  },
116
130
  ]
@@ -11,8 +11,8 @@ describe GraphQL::Schema::Printer do
11
11
  choice_type = GraphQL::EnumType.define do
12
12
  name "Choice"
13
13
 
14
- value "FOO"
15
- value "BAR"
14
+ value "FOO", value: :foo
15
+ value "BAR", value: :bar
16
16
  value "BAZ", deprecation_reason: 'Use "BAR".'
17
17
  value "WOZ", deprecation_reason: GraphQL::Directive::DEFAULT_DEPRECATION_REASON
18
18
  end
@@ -28,7 +28,7 @@ describe GraphQL::Schema::Printer do
28
28
  input_field :int, types.Int
29
29
  input_field :float, types.Float
30
30
  input_field :bool, types.Boolean
31
- input_field :enum, choice_type
31
+ input_field :enum, choice_type, default_value: :foo
32
32
  input_field :sub, types[sub_input_type]
33
33
  end
34
34
 
@@ -58,7 +58,7 @@ describe GraphQL::Schema::Printer do
58
58
  field :post do
59
59
  type post_type
60
60
  argument :id, !types.ID
61
- argument :varied, variant_input_type, default_value: { id: "123", int: 234, float: 2.3, enum: "FOO", sub: [{ string: "str" }] }
61
+ argument :varied, variant_input_type, default_value: { id: "123", int: 234, float: 2.3, enum: :foo, sub: [{ string: "str" }] }
62
62
  resolve -> (obj, args, ctx) { Post.find(args["id"]) }
63
63
  end
64
64
  end
@@ -211,7 +211,7 @@ input Varied {
211
211
  int: Int
212
212
  float: Float
213
213
  bool: Boolean
214
- enum: Choice
214
+ enum: Choice = FOO
215
215
  sub: [Sub]
216
216
  }
217
217
  SCHEMA
@@ -271,7 +271,12 @@ DairyAppQueryType = GraphQL::ObjectType.define do
271
271
  end
272
272
 
273
273
  field :allDairy, types[DairyProductUnion] do
274
- resolve -> (obj, args, ctx) { CHEESES.values + MILKS.values }
274
+ argument :executionErrorAtIndex, types.Int
275
+ resolve -> (obj, args, ctx) {
276
+ result = CHEESES.values + MILKS.values
277
+ result[args[:executionErrorAtIndex]] = GraphQL::ExecutionError.new("missing dairy") if args[:executionErrorAtIndex]
278
+ result
279
+ }
275
280
  end
276
281
 
277
282
  field :allEdible, types[EdibleInterface] do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.1
4
+ version: 0.19.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-04 00:00:00.000000000 Z
11
+ date: 2016-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter