rails-graphql 1.0.0.beta → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gql_parser.c +1 -16
  3. data/ext/gql_parser.h +21 -0
  4. data/ext/shared.c +0 -5
  5. data/ext/shared.h +6 -6
  6. data/lib/generators/graphql/channel_generator.rb +27 -0
  7. data/lib/generators/graphql/controller_generator.rb +9 -4
  8. data/lib/generators/graphql/install_generator.rb +49 -0
  9. data/lib/generators/graphql/schema_generator.rb +9 -4
  10. data/lib/generators/graphql/templates/channel.erb +7 -0
  11. data/lib/generators/graphql/templates/config.rb +97 -0
  12. data/lib/generators/graphql/templates/controller.erb +2 -0
  13. data/lib/generators/graphql/templates/schema.erb +5 -3
  14. data/lib/gql_parser.so +0 -0
  15. data/lib/rails/graphql/alternative/field_set.rb +12 -0
  16. data/lib/rails/graphql/alternative/query.rb +9 -4
  17. data/lib/rails/graphql/alternative/subscription.rb +2 -1
  18. data/lib/rails/graphql/argument.rb +5 -3
  19. data/lib/rails/graphql/callback.rb +8 -7
  20. data/lib/rails/graphql/collectors/hash_collector.rb +12 -1
  21. data/lib/rails/graphql/collectors/json_collector.rb +21 -0
  22. data/lib/rails/graphql/config.rb +73 -57
  23. data/lib/rails/graphql/directive/include_directive.rb +0 -1
  24. data/lib/rails/graphql/directive/skip_directive.rb +0 -1
  25. data/lib/rails/graphql/directive/specified_by_directive.rb +24 -0
  26. data/lib/rails/graphql/directive.rb +30 -24
  27. data/lib/rails/graphql/event.rb +7 -6
  28. data/lib/rails/graphql/field/authorized_field.rb +0 -5
  29. data/lib/rails/graphql/field/input_field.rb +0 -5
  30. data/lib/rails/graphql/field/mutation_field.rb +5 -6
  31. data/lib/rails/graphql/field/output_field.rb +13 -2
  32. data/lib/rails/graphql/field/proxied_field.rb +5 -5
  33. data/lib/rails/graphql/field/resolved_field.rb +1 -1
  34. data/lib/rails/graphql/field/subscription_field.rb +35 -52
  35. data/lib/rails/graphql/field/typed_field.rb +26 -2
  36. data/lib/rails/graphql/field.rb +20 -19
  37. data/lib/rails/graphql/global_id.rb +5 -1
  38. data/lib/rails/graphql/helpers/inherited_collection/array.rb +1 -0
  39. data/lib/rails/graphql/helpers/inherited_collection/base.rb +2 -0
  40. data/lib/rails/graphql/helpers/inherited_collection/hash.rb +2 -1
  41. data/lib/rails/graphql/helpers/registerable.rb +1 -1
  42. data/lib/rails/graphql/helpers/with_arguments.rb +3 -2
  43. data/lib/rails/graphql/helpers/with_callbacks.rb +3 -3
  44. data/lib/rails/graphql/helpers/with_description.rb +10 -8
  45. data/lib/rails/graphql/helpers/with_directives.rb +5 -1
  46. data/lib/rails/graphql/helpers/with_events.rb +1 -0
  47. data/lib/rails/graphql/helpers/with_fields.rb +28 -22
  48. data/lib/rails/graphql/helpers/with_name.rb +3 -2
  49. data/lib/rails/graphql/helpers/with_schema_fields.rb +72 -48
  50. data/lib/rails/graphql/introspection.rb +1 -1
  51. data/lib/rails/graphql/railtie.rb +3 -2
  52. data/lib/rails/graphql/railties/app/base_channel.rb +10 -0
  53. data/lib/rails/graphql/railties/app/base_controller.rb +12 -0
  54. data/lib/rails/graphql/railties/app/views/_cable.js.erb +56 -0
  55. data/lib/rails/graphql/railties/app/views/_fetch.js.erb +20 -0
  56. data/lib/rails/graphql/railties/app/views/graphiql.html.erb +101 -0
  57. data/lib/rails/graphql/railties/base_generator.rb +3 -9
  58. data/lib/rails/graphql/railties/channel.rb +8 -8
  59. data/lib/rails/graphql/railties/controller.rb +45 -24
  60. data/lib/rails/graphql/request/arguments.rb +2 -1
  61. data/lib/rails/graphql/request/backtrace.rb +31 -10
  62. data/lib/rails/graphql/request/component/field.rb +15 -8
  63. data/lib/rails/graphql/request/component/fragment.rb +13 -7
  64. data/lib/rails/graphql/request/component/operation/subscription.rb +4 -6
  65. data/lib/rails/graphql/request/component/operation.rb +11 -4
  66. data/lib/rails/graphql/request/component/spread.rb +13 -4
  67. data/lib/rails/graphql/request/component/typename.rb +1 -1
  68. data/lib/rails/graphql/request/component.rb +2 -0
  69. data/lib/rails/graphql/request/context.rb +1 -1
  70. data/lib/rails/graphql/request/event.rb +6 -2
  71. data/lib/rails/graphql/request/helpers/directives.rb +1 -0
  72. data/lib/rails/graphql/request/helpers/selection_set.rb +10 -4
  73. data/lib/rails/graphql/request/helpers/value_writers.rb +8 -5
  74. data/lib/rails/graphql/request/prepared_data.rb +3 -1
  75. data/lib/rails/graphql/request/steps/organizable.rb +1 -1
  76. data/lib/rails/graphql/request/steps/preparable.rb +1 -1
  77. data/lib/rails/graphql/request/steps/resolvable.rb +1 -1
  78. data/lib/rails/graphql/request/strategy/sequenced_strategy.rb +3 -3
  79. data/lib/rails/graphql/request/strategy.rb +18 -4
  80. data/lib/rails/graphql/request/subscription.rb +18 -16
  81. data/lib/rails/graphql/request.rb +67 -37
  82. data/lib/rails/graphql/schema.rb +39 -86
  83. data/lib/rails/graphql/shortcuts.rb +11 -5
  84. data/lib/rails/graphql/source/active_record/builders.rb +20 -21
  85. data/lib/rails/graphql/source/active_record_source.rb +93 -33
  86. data/lib/rails/graphql/source/base.rb +11 -39
  87. data/lib/rails/graphql/source/builder.rb +9 -22
  88. data/lib/rails/graphql/source/scoped_arguments.rb +10 -4
  89. data/lib/rails/graphql/source.rb +23 -37
  90. data/lib/rails/graphql/subscription/provider/action_cable.rb +10 -9
  91. data/lib/rails/graphql/subscription/provider/base.rb +6 -5
  92. data/lib/rails/graphql/subscription/store/base.rb +5 -9
  93. data/lib/rails/graphql/subscription/store/memory.rb +18 -9
  94. data/lib/rails/graphql/type/creator.rb +196 -0
  95. data/lib/rails/graphql/type/enum.rb +17 -9
  96. data/lib/rails/graphql/type/input.rb +20 -4
  97. data/lib/rails/graphql/type/interface.rb +15 -4
  98. data/lib/rails/graphql/type/object/directive_object.rb +6 -5
  99. data/lib/rails/graphql/type/object/input_value_object.rb +3 -4
  100. data/lib/rails/graphql/type/object/type_object.rb +40 -13
  101. data/lib/rails/graphql/type/object.rb +10 -5
  102. data/lib/rails/graphql/type/scalar/binary_scalar.rb +2 -0
  103. data/lib/rails/graphql/type/scalar/date_scalar.rb +2 -0
  104. data/lib/rails/graphql/type/scalar/date_time_scalar.rb +2 -0
  105. data/lib/rails/graphql/type/scalar/decimal_scalar.rb +2 -0
  106. data/lib/rails/graphql/type/scalar/json_scalar.rb +3 -1
  107. data/lib/rails/graphql/type/scalar/time_scalar.rb +3 -1
  108. data/lib/rails/graphql/type/scalar.rb +1 -1
  109. data/lib/rails/graphql/type/union.rb +7 -2
  110. data/lib/rails/graphql/type.rb +10 -2
  111. data/lib/rails/graphql/type_map.rb +18 -7
  112. data/lib/rails/graphql/uri.rb +5 -4
  113. data/lib/rails/graphql/version.rb +6 -2
  114. data/lib/rails/graphql.rb +9 -7
  115. data/test/assets/introspection-mem.txt +1 -1
  116. data/test/assets/introspection.gql +2 -0
  117. data/test/assets/mem.gql +74 -60
  118. data/test/assets/mysql.gql +69 -55
  119. data/test/assets/sqlite.gql +78 -64
  120. data/test/assets/translate.gql +50 -39
  121. data/test/config.rb +2 -1
  122. data/test/graphql/schema_test.rb +2 -31
  123. data/test/graphql/source_test.rb +0 -10
  124. data/test/graphql/type/interface_test.rb +8 -5
  125. data/test/graphql/type/object_test.rb +8 -2
  126. data/test/graphql/type_map_test.rb +13 -16
  127. data/test/integration/global_id_test.rb +4 -4
  128. data/test/integration/memory/star_wars_validation_test.rb +2 -2
  129. data/test/integration/mysql/star_wars_introspection_test.rb +1 -1
  130. data/test/integration/resolver_precedence_test.rb +1 -1
  131. data/test/integration/schemas/memory.rb +3 -4
  132. data/test/integration/sqlite/star_wars_global_id_test.rb +27 -21
  133. data/test/integration/sqlite/star_wars_introspection_test.rb +1 -1
  134. data/test/integration/translate_test.rb +26 -14
  135. metadata +20 -7
@@ -16,22 +16,22 @@ scalar Bigint
16
16
  The Binary scalar type represents a Base64 string.
17
17
  Normally used to share files and uploads.
18
18
  """
19
- scalar Binary
19
+ scalar Binary @specifiedBy(url: "https://www.rfc-editor.org/rfc/rfc3548")
20
20
 
21
21
  "The Boolean scalar type represents true or false."
22
22
  scalar Boolean
23
23
 
24
24
  "The Date scalar type represents a ISO 8601 string value."
25
- scalar Date
25
+ scalar Date @specifiedBy(url: "https://www.rfc-editor.org/rfc/rfc3339")
26
26
 
27
27
  "The DateTime scalar type represents a ISO 8601 string value."
28
- scalar DateTime
28
+ scalar DateTime @specifiedBy(url: "https://www.rfc-editor.org/rfc/rfc3339")
29
29
 
30
30
  """
31
31
  The Decimal scalar type represents signed fractional values with extra precision.
32
32
  The values are exchange as string.
33
33
  """
34
- scalar Decimal
34
+ scalar Decimal @specifiedBy(url: "https://en.wikipedia.org/wiki/IEEE_754-2008_revision")
35
35
 
36
36
  "The Float scalar type represents signed double-precision fractional values."
37
37
  scalar Float
@@ -47,9 +47,9 @@ scalar Int
47
47
 
48
48
  """
49
49
  The JSON scalar type represents an unstructured JSON data
50
- with all its available kyes and values.
50
+ with all its available keys and values.
51
51
  """
52
- scalar JSON
52
+ scalar JSON @specifiedBy(url: "https://www.rfc-editor.org/rfc/rfc8259")
53
53
 
54
54
  """
55
55
  The String scalar type represents textual data, represented as UTF-8 character
@@ -59,9 +59,9 @@ scalar String
59
59
 
60
60
  """
61
61
  The Time scalar type that represents a distance in time using hours,
62
- minutes, seconds, and miliseconds.
62
+ minutes, seconds, and milliseconds.
63
63
  """
64
- scalar Time
64
+ scalar Time @specifiedBy(url: "https://www.rfc-editor.org/rfc/rfc3339")
65
65
 
66
66
  "The valid locations that a directive may be placed."
67
67
  enum __DirectiveLocation {
@@ -154,25 +154,25 @@ enum __TypeKind {
154
154
  input LiteBaseInput {
155
155
  id: ID
156
156
 
157
+ _delete: Boolean = false
158
+
157
159
  factionId: ID
158
160
 
159
161
  name: String!
160
162
 
161
163
  planet: String
162
-
163
- _delete: Boolean = false
164
164
  }
165
165
 
166
166
  # Assigned to LiteFaction class
167
167
  input LiteFactionInput {
168
168
  id: ID
169
169
 
170
- name: String
171
-
172
170
  _delete: Boolean = false
173
171
 
174
172
  basesAttributes: [LiteBaseInput!]
175
173
 
174
+ name: String
175
+
176
176
  shipsAttributes: [LiteShipInput!]
177
177
  }
178
178
 
@@ -180,34 +180,34 @@ input LiteFactionInput {
180
180
  input LiteShipInput {
181
181
  id: ID
182
182
 
183
+ _delete: Boolean = false
184
+
183
185
  factionId: ID
184
186
 
185
187
  name: String
186
-
187
- _delete: Boolean = false
188
188
  }
189
189
 
190
190
  # Assigned to LiteBase class
191
191
  type LiteBase {
192
192
  id: ID!
193
193
 
194
+ faction: LiteFaction
195
+
194
196
  factionId: ID
195
197
 
196
198
  name: String!
197
199
 
198
200
  planet: String
199
-
200
- faction: LiteFaction
201
201
  }
202
202
 
203
203
  # Assigned to LiteFaction class
204
204
  type LiteFaction {
205
205
  id: ID!
206
206
 
207
- name: String
208
-
209
207
  bases: [LiteBase!]!
210
208
 
209
+ name: String
210
+
211
211
  ships: [LiteShip!]!
212
212
  }
213
213
 
@@ -215,31 +215,31 @@ type LiteFaction {
215
215
  type LiteShip {
216
216
  id: ID!
217
217
 
218
+ faction: LiteFaction
219
+
218
220
  factionId: ID
219
221
 
220
222
  name: String
221
-
222
- faction: LiteFaction
223
223
  }
224
224
 
225
225
  type _Mutation {
226
+ createLiteBase(liteBase: LiteBaseInput!): LiteBase!
227
+
226
228
  createLiteFaction(liteFaction: LiteFactionInput!): LiteFaction!
227
229
 
228
- updateLiteFaction(id: ID!, liteFaction: LiteFactionInput!): LiteFaction!
230
+ createLiteShip(liteShip: LiteShipInput!): LiteShip!
231
+
232
+ deleteLiteBase(id: ID!): Boolean!
229
233
 
230
234
  deleteLiteFaction(id: ID!): Boolean!
231
235
 
232
- createLiteBase(liteBase: LiteBaseInput!): LiteBase!
236
+ deleteLiteShip(id: ID!): Boolean!
233
237
 
234
238
  updateLiteBase(id: ID!, liteBase: LiteBaseInput!): LiteBase!
235
239
 
236
- deleteLiteBase(id: ID!): Boolean!
237
-
238
- createLiteShip(liteShip: LiteShipInput!): LiteShip!
240
+ updateLiteFaction(id: ID!, liteFaction: LiteFactionInput!): LiteFaction!
239
241
 
240
242
  updateLiteShip(id: ID!, liteShip: LiteShipInput!): LiteShip!
241
-
242
- deleteLiteShip(id: ID!): Boolean!
243
243
  }
244
244
 
245
245
  type _Query {
@@ -247,17 +247,17 @@ type _Query {
247
247
 
248
248
  __type(name: String!): __Type
249
249
 
250
- liteFactions(order: String): [LiteFaction!]!
251
-
252
- liteFaction(id: ID!): LiteFaction!
250
+ liteBase(id: ID!): LiteBase!
253
251
 
254
252
  liteBases(order: String = "desc"): [LiteBase!]!
255
253
 
256
- liteBase(id: ID!): LiteBase!
254
+ liteFaction(id: ID!): LiteFaction!
257
255
 
258
- liteShips: [LiteShip!]!
256
+ liteFactions(order: String): [LiteFaction!]!
259
257
 
260
258
  liteShip(id: ID!): LiteShip!
259
+
260
+ liteShips: [LiteShip!]!
261
261
  }
262
262
 
263
263
  """
@@ -271,13 +271,15 @@ additional information to the executor.
271
271
  """
272
272
  # Assigned to Rails::GraphQL::Directive class
273
273
  type __Directive {
274
- name: String!
274
+ args: [__InputValue!]!
275
275
 
276
276
  description: String
277
277
 
278
+ isRepeatable: Boolean!
279
+
278
280
  locations: [__DirectiveLocation!]!
279
281
 
280
- args: [__InputValue!]!
282
+ name: String!
281
283
  }
282
284
 
283
285
  """
@@ -286,13 +288,13 @@ of values. It's a string representation, not a numeric representation,
286
288
  of a value kept as all caps (ie. ONE_VALUE).
287
289
  """
288
290
  type __EnumValue {
289
- name: String!
291
+ deprecationReason: String
290
292
 
291
293
  description: String
292
294
 
293
295
  isDeprecated: Boolean!
294
296
 
295
- deprecationReason: String
297
+ name: String!
296
298
  }
297
299
 
298
300
  """
@@ -302,34 +304,33 @@ a value of a specific type.
302
304
  """
303
305
  # Assigned to Rails::GraphQL::Field class
304
306
  type __Field {
305
- name: String!
306
-
307
- description: String
308
-
309
307
  args: [__InputValue!]!
310
308
 
311
- type: __Type!
309
+ deprecationReason: String
310
+
311
+ description: String
312
312
 
313
313
  isDeprecated: Boolean!
314
314
 
315
- deprecationReason: String
315
+ name: String!
316
+
317
+ type: __Type!
316
318
  }
317
319
 
318
320
  """
319
- Alongside with scalars and enums, input value objects allow the user
320
- to provide values to arguments on fields and directives. Different
321
- from those, input values accepts a list of keyed values, instead of
322
- a single value.
321
+ Arguments provided to Fields or Directives and the input fields of an
322
+ InputObject are represented as Input Values which describe their type
323
+ and optionally a default value.
323
324
  """
324
325
  # Assigned to Rails::GraphQL::Field::InputField class
325
326
  type __InputValue {
326
- name: String!
327
+ defaultValue: String
327
328
 
328
329
  description: String
329
330
 
330
- type: __Type!
331
+ name: String!
331
332
 
332
- defaultValue: String
333
+ type: __Type!
333
334
  }
334
335
 
335
336
  """
@@ -341,15 +342,15 @@ determines the place in the type system where those operations begin.
341
342
  """
342
343
  # Assigned to Rails::GraphQL::Schema class
343
344
  type __Schema {
344
- types: [__Type!]!
345
-
346
- queryType: __Type!
345
+ directives: [__Directive!]!
347
346
 
348
347
  mutationType: __Type
349
348
 
349
+ queryType: __Type!
350
+
350
351
  subscriptionType: __Type
351
352
 
352
- directives: [__Directive!]!
353
+ types: [__Type!]!
353
354
  }
354
355
 
355
356
  """
@@ -375,29 +376,31 @@ the schema to define exactly what data is expected.
375
376
  """
376
377
  # Assigned to Rails::GraphQL::Type class
377
378
  type __Type {
378
- kind: __TypeKind!
379
-
380
- name: String
381
-
382
379
  description: String
383
380
 
381
+ "ENUM only"
382
+ enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
383
+
384
384
  "OBJECT and INTERFACE only"
385
385
  fields(includeDeprecated: Boolean = false): [__Field!]
386
386
 
387
+ "INPUT_OBJECT only"
388
+ inputFields: [__InputValue!]
389
+
387
390
  "OBJECT only"
388
391
  interfaces: [__Type!]
389
392
 
390
- "INTERFACE and UNION only"
391
- possibleTypes: [__Type!]
392
-
393
- "ENUM only"
394
- enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
393
+ kind: __TypeKind!
395
394
 
396
- "INPUT_OBJECT only"
397
- inputFields: [__InputValue!]
395
+ name: String
398
396
 
399
397
  "NON_NULL and LIST only"
400
398
  ofType: __Type
399
+
400
+ "INTERFACE and UNION only"
401
+ possibleTypes: [__Type!]
402
+
403
+ specifiedByURL: String
401
404
  }
402
405
 
403
406
  """
@@ -430,3 +433,14 @@ directive @skip(
430
433
  if: Boolean!
431
434
 
432
435
  ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
436
+
437
+ """
438
+ A built-in directive used within the type system definition language to provide
439
+ a scalar specification URL for specifying the behavior of custom scalar types.
440
+ """
441
+ directive @specifiedBy(
442
+
443
+ "Point to a human-readable specification of the data format."
444
+ url: String!
445
+
446
+ ) on SCALAR
@@ -137,8 +137,9 @@ type ObjectDesc {
137
137
  }
138
138
 
139
139
  type _Query {
140
- "Field"
141
- sampleField: String
140
+ __schema: __Schema!
141
+
142
+ __type(name: String!): __Type
142
143
 
143
144
  "A"
144
145
  sampleA: String
@@ -149,18 +150,14 @@ type _Query {
149
150
  "C"
150
151
  sampleC: String
151
152
 
152
- "D"
153
153
  sampleD: String
154
154
 
155
155
  "E"
156
156
  sampleE: String
157
157
 
158
- "F"
159
158
  sampleF: String
160
159
 
161
- __schema: __Schema!
162
-
163
- __type(name: String!): __Type
160
+ sampleField: String
164
161
  }
165
162
 
166
163
  """
@@ -174,13 +171,15 @@ additional information to the executor.
174
171
  """
175
172
  # Assigned to Rails::GraphQL::Directive class
176
173
  type __Directive {
177
- name: String!
174
+ args: [__InputValue!]!
178
175
 
179
176
  description: String
180
177
 
178
+ isRepeatable: Boolean!
179
+
181
180
  locations: [__DirectiveLocation!]!
182
181
 
183
- args: [__InputValue!]!
182
+ name: String!
184
183
  }
185
184
 
186
185
  """
@@ -189,13 +188,13 @@ of values. It's a string representation, not a numeric representation,
189
188
  of a value kept as all caps (ie. ONE_VALUE).
190
189
  """
191
190
  type __EnumValue {
192
- name: String!
191
+ deprecationReason: String
193
192
 
194
193
  description: String
195
194
 
196
195
  isDeprecated: Boolean!
197
196
 
198
- deprecationReason: String
197
+ name: String!
199
198
  }
200
199
 
201
200
  """
@@ -205,34 +204,33 @@ a value of a specific type.
205
204
  """
206
205
  # Assigned to Rails::GraphQL::Field class
207
206
  type __Field {
208
- name: String!
209
-
210
- description: String
211
-
212
207
  args: [__InputValue!]!
213
208
 
214
- type: __Type!
209
+ deprecationReason: String
210
+
211
+ description: String
215
212
 
216
213
  isDeprecated: Boolean!
217
214
 
218
- deprecationReason: String
215
+ name: String!
216
+
217
+ type: __Type!
219
218
  }
220
219
 
221
220
  """
222
- Alongside with scalars and enums, input value objects allow the user
223
- to provide values to arguments on fields and directives. Different
224
- from those, input values accepts a list of keyed values, instead of
225
- a single value.
221
+ Arguments provided to Fields or Directives and the input fields of an
222
+ InputObject are represented as Input Values which describe their type
223
+ and optionally a default value.
226
224
  """
227
225
  # Assigned to Rails::GraphQL::Field::InputField class
228
226
  type __InputValue {
229
- name: String!
227
+ defaultValue: String
230
228
 
231
229
  description: String
232
230
 
233
- type: __Type!
231
+ name: String!
234
232
 
235
- defaultValue: String
233
+ type: __Type!
236
234
  }
237
235
 
238
236
  """
@@ -244,15 +242,15 @@ determines the place in the type system where those operations begin.
244
242
  """
245
243
  # Assigned to Rails::GraphQL::Schema class
246
244
  type __Schema {
247
- types: [__Type!]!
248
-
249
- queryType: __Type!
245
+ directives: [__Directive!]!
250
246
 
251
247
  mutationType: __Type
252
248
 
249
+ queryType: __Type!
250
+
253
251
  subscriptionType: __Type
254
252
 
255
- directives: [__Directive!]!
253
+ types: [__Type!]!
256
254
  }
257
255
 
258
256
  """
@@ -278,29 +276,31 @@ the schema to define exactly what data is expected.
278
276
  """
279
277
  # Assigned to Rails::GraphQL::Type class
280
278
  type __Type {
281
- kind: __TypeKind!
282
-
283
- name: String
284
-
285
279
  description: String
286
280
 
281
+ "ENUM only"
282
+ enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
283
+
287
284
  "OBJECT and INTERFACE only"
288
285
  fields(includeDeprecated: Boolean = false): [__Field!]
289
286
 
287
+ "INPUT_OBJECT only"
288
+ inputFields: [__InputValue!]
289
+
290
290
  "OBJECT only"
291
291
  interfaces: [__Type!]
292
292
 
293
- "INTERFACE and UNION only"
294
- possibleTypes: [__Type!]
295
-
296
- "ENUM only"
297
- enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
293
+ kind: __TypeKind!
298
294
 
299
- "INPUT_OBJECT only"
300
- inputFields: [__InputValue!]
295
+ name: String
301
296
 
302
297
  "NON_NULL and LIST only"
303
298
  ofType: __Type
299
+
300
+ "INTERFACE and UNION only"
301
+ possibleTypes: [__Type!]
302
+
303
+ specifiedByURL: String
304
304
  }
305
305
 
306
306
  """
@@ -333,3 +333,14 @@ directive @skip(
333
333
  if: Boolean!
334
334
 
335
335
  ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
336
+
337
+ """
338
+ A built-in directive used within the type system definition language to provide
339
+ a scalar specification URL for specifying the behavior of custom scalar types.
340
+ """
341
+ directive @specifiedBy(
342
+
343
+ "Point to a human-readable specification of the data format."
344
+ url: String!
345
+
346
+ ) on SCALAR
data/test/config.rb CHANGED
@@ -17,10 +17,11 @@ require 'minitest/autorun'
17
17
  require 'minitest/reporters'
18
18
  require 'active_record'
19
19
  require 'rails-graphql'
20
- require 'debug'
20
+ require 'pry-byebug'
21
21
 
22
22
  $config = Rails::GraphQL.config
23
23
  $config.logger = ActiveSupport::TaggedLogging.new(Logger.new('/dev/null'))
24
+ $config.enable_introspection = true
24
25
  Rails::GraphQL::Request::Backtrace.skip_base_class = NilClass
25
26
 
26
27
  # ActiveRecord::Base.logger = Logger.new(STDOUT)
@@ -4,8 +4,8 @@ class GraphQL_SchemaTest < GraphQL::TestCase
4
4
  DESCRIBED_CLASS = unmapped_class(Rails::GraphQL::Schema)
5
5
 
6
6
  def test_gql_name
7
- assert_equal('schema', DESCRIBED_CLASS.gql_name)
8
- assert_equal('schema', DESCRIBED_CLASS.graphql_name)
7
+ assert_equal('__Schema', DESCRIBED_CLASS.gql_name)
8
+ assert_equal('__Schema', DESCRIBED_CLASS.graphql_name)
9
9
  end
10
10
 
11
11
  def test_kind
@@ -120,29 +120,6 @@ class GraphQL_SchemaTest < GraphQL::TestCase
120
120
  end
121
121
  end
122
122
 
123
- def test_create_type
124
- DESCRIBED_CLASS.stub(:create_klass, passallthrough) do
125
- other = double(Module.new, base_type: double(name: 'A::Sample'))
126
- result = [:some, other, type_const, { suffix: 'Sample' }]
127
- assert_equal(result, DESCRIBED_CLASS.send(:create_type, :some, other))
128
-
129
- result = [:some, type_const::Scalar, type_const, { suffix: 'Scalar' }]
130
- assert_equal(result, DESCRIBED_CLASS.send(:create_type, :some, :Scalar))
131
- end
132
- end
133
-
134
- def test_source
135
- DESCRIBED_CLASS.stub(:create_klass, passallthrough) do
136
- result = [:some, 1, source_const, { suffix: 'Source' }]
137
- assert_equal(result, DESCRIBED_CLASS.send(:source, :some, 1))
138
-
139
- source_const.stub(:find_for!, 2) do
140
- result = [:some, 2, source_const, { suffix: 'Source' }]
141
- assert_equal(result, DESCRIBED_CLASS.send(:source, :some))
142
- end
143
- end
144
- end
145
-
146
123
  def test_sources
147
124
  result, passthrough = collect_all_through
148
125
  xargs = { build: true }
@@ -160,12 +137,6 @@ class GraphQL_SchemaTest < GraphQL::TestCase
160
137
  end
161
138
  end
162
139
 
163
- def test_create_klass
164
- skip 'Needs branching testing'
165
- new_klass = DESCRIBED_CLASS.send :create_klass, 'Test', unmapped_class(type_const::Enum)
166
- assert(new_klass < type_const::Enum)
167
- end
168
-
169
140
  protected
170
141
 
171
142
  def type_const
@@ -144,16 +144,6 @@ class GraphQL_SourceTest < GraphQL::TestCase
144
144
  end
145
145
  end
146
146
 
147
- def test_gql_module
148
- assert_equal(::GraphQL, described_class.send(:gql_module))
149
-
150
- ::GraphQL.stub_const(:Other, Module.new) do
151
- sample = unmapped_class(source_const)
152
- ::GraphQL::Other.const_set(:Source, sample)
153
- assert_equal(::GraphQL::Other, sample.send(:gql_module))
154
- end
155
- end
156
-
157
147
  def test_build_bang
158
148
  skip
159
149
  end
@@ -31,20 +31,23 @@ class GraphQL_Type_InterfaceTest < GraphQL::TestCase
31
31
  end
32
32
 
33
33
  def test_implemented
34
+ skip 'Needs better double of interface'
34
35
  DESCRIBED_CLASS.stub(:gql_name, 'test') do
35
36
  DESCRIBED_CLASS.stub(:fields, {}) do
36
- object = double(gql_name: 'baz', field?: ->(*) { false }, proxy_field: -> {})
37
+ object = double(gql_name: 'baz', has_field?: ->(*) { false }, proxy_field: -> {})
37
38
  assert_equal(Set[object], implemented_types(object))
38
39
  end
39
40
 
40
- DESCRIBED_CLASS.stub(:fields, { 'a' => 'b' }) do
41
- object = double(gql_name: 'baz', field?: ->(*) { true }, fields: { 'a' => /b/ })
41
+ field = double(name: 'a', :"=~" => ->(*) { true })
42
+ DESCRIBED_CLASS.stub(:fields, { 'a' => field }) do
43
+ object = double(gql_name: 'baz', has_field?: ->(*) { true }, fields: { 'a' => field })
42
44
  assert_equal(Set[object], implemented_types(object))
43
45
  end
44
46
 
45
- fields = { 'a' => double(gql_name: 'a') }
47
+ field = double(name: 'a', :"=~" => ->(*) { false })
48
+ fields = { 'a' => field }
46
49
  DESCRIBED_CLASS.stub(:fields, fields) do
47
- object = double(gql_name: 'baz', field?: ->(*) { true }, fields: { 'a' => 'b' })
50
+ object = double(gql_name: 'baz', has_field?: ->(*) { true }, fields: { 'a' => field })
48
51
  assert_raises(StandardError) { DESCRIBED_CLASS.implemented(object) }
49
52
  end
50
53
  end
@@ -5,14 +5,17 @@ class GraphQL_Type_ObjectTest < GraphQL::TestCase
5
5
 
6
6
  def test_valid_member_ask
7
7
  fields = {
8
- name: double(method_name: :name),
9
- age: double(method_name: :age),
8
+ name: double(method_name: :name, null?: true, gql_name: 'n'),
9
+ age: double(method_name: :age, null?: false, gql_name: 'a'),
10
10
  }
11
11
 
12
12
  DESCRIBED_CLASS.stub(:fields, fields) do
13
13
  value = { name: '' }
14
14
  refute(DESCRIBED_CLASS.valid_member?(value))
15
15
 
16
+ value = { age: 0 }
17
+ assert(DESCRIBED_CLASS.valid_member?(value))
18
+
16
19
  value = { name: '', age: 0 }
17
20
  assert(DESCRIBED_CLASS.valid_member?(value))
18
21
 
@@ -20,6 +23,9 @@ class GraphQL_Type_ObjectTest < GraphQL::TestCase
20
23
  assert(DESCRIBED_CLASS.valid_member?(value))
21
24
 
22
25
  value = { 'name' => '', 'age' => 0 }
26
+ refute(DESCRIBED_CLASS.valid_member?(value))
27
+
28
+ value = { 'n' => '', 'a' => 0 }
23
29
  assert(DESCRIBED_CLASS.valid_member?(value))
24
30
 
25
31
  value = double(name: '', age: 0)