graphql 0.16.1 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/analysis/query_complexity.rb +20 -13
  3. data/lib/graphql/analysis/query_depth.rb +2 -2
  4. data/lib/graphql/argument.rb +7 -2
  5. data/lib/graphql/base_type.rb +2 -1
  6. data/lib/graphql/boolean_type.rb +1 -0
  7. data/lib/graphql/define/assign_object_field.rb +19 -6
  8. data/lib/graphql/define/instance_definable.rb +44 -3
  9. data/lib/graphql/directive.rb +2 -6
  10. data/lib/graphql/enum_type.rb +11 -14
  11. data/lib/graphql/field.rb +47 -12
  12. data/lib/graphql/field/resolve.rb +57 -0
  13. data/lib/graphql/float_type.rb +2 -0
  14. data/lib/graphql/id_type.rb +2 -0
  15. data/lib/graphql/input_object_type.rb +5 -1
  16. data/lib/graphql/int_type.rb +2 -0
  17. data/lib/graphql/interface_type.rb +1 -1
  18. data/lib/graphql/internal_representation/node.rb +18 -29
  19. data/lib/graphql/internal_representation/rewrite.rb +7 -4
  20. data/lib/graphql/introspection/field_type.rb +1 -1
  21. data/lib/graphql/introspection/input_value_type.rb +1 -1
  22. data/lib/graphql/language/parser.rb +161 -136
  23. data/lib/graphql/language/parser.y +9 -1
  24. data/lib/graphql/object_type.rb +2 -2
  25. data/lib/graphql/query.rb +4 -4
  26. data/lib/graphql/query/directive_resolution.rb +2 -2
  27. data/lib/graphql/query/serial_execution/execution_context.rb +3 -2
  28. data/lib/graphql/query/serial_execution/field_resolution.rb +2 -5
  29. data/lib/graphql/query/serial_execution/selection_resolution.rb +1 -1
  30. data/lib/graphql/query/serial_execution/value_resolution.rb +2 -2
  31. data/lib/graphql/scalar_type.rb +2 -0
  32. data/lib/graphql/schema/timeout_middleware.rb +1 -0
  33. data/lib/graphql/string_type.rb +2 -0
  34. data/lib/graphql/union_type.rb +1 -1
  35. data/lib/graphql/version.rb +1 -1
  36. data/readme.md +1 -3
  37. data/spec/graphql/analysis/query_complexity_spec.rb +41 -5
  38. data/spec/graphql/define/instance_definable_spec.rb +2 -2
  39. data/spec/graphql/field_spec.rb +18 -0
  40. data/spec/graphql/internal_representation/rewrite_spec.rb +7 -6
  41. data/spec/graphql/language/parser_spec.rb +5 -0
  42. data/spec/graphql/query/serial_execution/execution_context_spec.rb +2 -1
  43. data/spec/graphql/schema/timeout_middleware_spec.rb +29 -28
  44. data/spec/support/dairy_app.rb +12 -10
  45. metadata +3 -3
  46. data/lib/graphql/internal_representation/definition.rb +0 -0
@@ -27,7 +27,7 @@ end
27
27
  CheeseType = GraphQL::ObjectType.define do
28
28
  name "Cheese"
29
29
  description "Cultured dairy product"
30
- interfaces ["EdibleInterface", -> { AnimalProductInterface }]
30
+ interfaces [EdibleInterface, AnimalProductInterface]
31
31
 
32
32
  # Can have (name, type, desc)
33
33
  field :id, !types.Int, "Unique identifier"
@@ -37,8 +37,8 @@ CheeseType = GraphQL::ObjectType.define do
37
37
  field :source, !DairyAnimalEnum,
38
38
  "Animal which produced the milk for this cheese"
39
39
 
40
- # Or can define by block:
41
- field :similarCheese, -> { CheeseType }, "Cheeses like this one" do
40
+ # Or can define by block, `resolve ->` should override `property:`
41
+ field :similarCheese, CheeseType, "Cheeses like this one", property: :nonsense do
42
42
  argument :source, !types[!DairyAnimalEnum]
43
43
  resolve -> (t, a, c) {
44
44
  # get the strings out:
@@ -51,12 +51,12 @@ CheeseType = GraphQL::ObjectType.define do
51
51
  }
52
52
  end
53
53
 
54
- field :nullableCheese, -> { CheeseType }, "Cheeses like this one" do
54
+ field :nullableCheese, CheeseType, "Cheeses like this one" do
55
55
  argument :source, types[!DairyAnimalEnum]
56
56
  resolve -> (t, a, c) { raise("NotImplemented") }
57
57
  end
58
58
 
59
- field :deeplyNullableCheese, -> { CheeseType }, "Cheeses like this one" do
59
+ field :deeplyNullableCheese, CheeseType, "Cheeses like this one" do
60
60
  argument :source, types[types[DairyAnimalEnum]]
61
61
  resolve -> (t, a, c) { raise("NotImplemented") }
62
62
  end
@@ -73,7 +73,7 @@ MilkType = GraphQL::ObjectType.define do
73
73
  description "Dairy beverage"
74
74
  interfaces [EdibleInterface, AnimalProductInterface]
75
75
  field :id, !types.ID
76
- field :source, DairyAnimalEnum, "Animal which produced this milk"
76
+ field :source, DairyAnimalEnum, "Animal which produced this milk", hash_key: :source
77
77
  field :origin, !types.String, "Place the milk comes from"
78
78
  field :flavors, types[types.String], "Chocolate, Strawberry, etc" do
79
79
  argument :limit, types.Int
@@ -113,6 +113,7 @@ end
113
113
  DairyProductUnion = GraphQL::UnionType.define do
114
114
  name "DairyProduct"
115
115
  description "Kinds of food made from milk"
116
+ # Test that these forms of declaration still work:
116
117
  possible_types ["MilkType", -> { CheeseType }]
117
118
  end
118
119
 
@@ -163,7 +164,7 @@ DeepNonNullType = GraphQL::ObjectType.define do
163
164
  resolve -> (obj, args, ctx) { args[:returning] }
164
165
  end
165
166
 
166
- field :deepNonNull, -> { DeepNonNullType.to_non_null_type } do
167
+ field :deepNonNull, DeepNonNullType.to_non_null_type do
167
168
  resolve -> (obj, args, ctx) { :deepNonNull }
168
169
  end
169
170
  end
@@ -208,11 +209,12 @@ SourceFieldDefn = Proc.new {
208
209
  }
209
210
  }
210
211
 
211
- FavoriteFieldDefn = Proc.new {
212
+ FavoriteFieldDefn = GraphQL::Field.define do
213
+ name "favoriteEdible"
212
214
  description "My favorite food"
213
215
  type EdibleInterface
214
216
  resolve -> (t, a, c) { MILKS[1] }
215
- }
217
+ end
216
218
 
217
219
  QueryType = GraphQL::ObjectType.define do
218
220
  name "Query"
@@ -224,7 +226,7 @@ QueryType = GraphQL::ObjectType.define do
224
226
  field :milk, field: FetchField.create(type: MilkType, data: MILKS, id_type: !types.ID)
225
227
  field :dairy, field: SingletonField.create(type: DairyType, data: DAIRY)
226
228
  field :fromSource, &SourceFieldDefn
227
- field :favoriteEdible, &FavoriteFieldDefn
229
+ field :favoriteEdible, FavoriteFieldDefn
228
230
  field :cow, field: SingletonField.create(type: CowType, data: COW)
229
231
  field :searchDairy do
230
232
  description "Find dairy products matching a description"
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.16.1
4
+ version: 0.17.0
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-07-20 00:00:00.000000000 Z
11
+ date: 2016-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter
@@ -213,13 +213,13 @@ files:
213
213
  - lib/graphql/enum_type.rb
214
214
  - lib/graphql/execution_error.rb
215
215
  - lib/graphql/field.rb
216
+ - lib/graphql/field/resolve.rb
216
217
  - lib/graphql/float_type.rb
217
218
  - lib/graphql/id_type.rb
218
219
  - lib/graphql/input_object_type.rb
219
220
  - lib/graphql/int_type.rb
220
221
  - lib/graphql/interface_type.rb
221
222
  - lib/graphql/internal_representation.rb
222
- - lib/graphql/internal_representation/definition.rb
223
223
  - lib/graphql/internal_representation/node.rb
224
224
  - lib/graphql/internal_representation/rewrite.rb
225
225
  - lib/graphql/introspection.rb
File without changes