gqli 0.6.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/CHANGELOG.md +17 -0
  4. data/Gemfile.lock +103 -82
  5. data/README.md +0 -5
  6. data/coverage/.last_run.json +1 -1
  7. data/coverage/.resultset.json +1774 -1205
  8. data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc.png +0 -0
  9. data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc_disabled.png +0 -0
  10. data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_both.png +0 -0
  11. data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc.png +0 -0
  12. data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc_disabled.png +0 -0
  13. data/coverage/assets/0.12.3/application.css +1 -0
  14. data/coverage/assets/0.12.3/application.js +7 -0
  15. data/coverage/assets/{0.10.2 → 0.12.3}/colorbox/border.png +0 -0
  16. data/coverage/assets/{0.10.2 → 0.12.3}/colorbox/controls.png +0 -0
  17. data/coverage/assets/{0.10.2 → 0.12.3}/colorbox/loading.gif +0 -0
  18. data/coverage/assets/{0.10.2 → 0.12.3}/colorbox/loading_background.png +0 -0
  19. data/coverage/assets/{0.10.2 → 0.12.3}/favicon_green.png +0 -0
  20. data/coverage/assets/{0.10.2 → 0.12.3}/favicon_red.png +0 -0
  21. data/coverage/assets/{0.10.2 → 0.12.3}/favicon_yellow.png +0 -0
  22. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  23. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  24. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  25. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  26. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  27. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  28. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  29. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  30. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-icons_222222_256x240.png +0 -0
  31. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-icons_2e83ff_256x240.png +0 -0
  32. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-icons_454545_256x240.png +0 -0
  33. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-icons_888888_256x240.png +0 -0
  34. data/coverage/assets/{0.10.2/smoothness → 0.12.3}/images/ui-icons_cd0a0a_256x240.png +0 -0
  35. data/coverage/assets/{0.10.2 → 0.12.3}/loading.gif +0 -0
  36. data/coverage/assets/{0.10.2 → 0.12.3}/magnify.png +0 -0
  37. data/coverage/index.html +19376 -7403
  38. data/doc/GQLi/Base.html +11 -11
  39. data/doc/GQLi/Client.html +175 -41
  40. data/doc/GQLi/Contentful.html +13 -11
  41. data/doc/GQLi/DSL.html +298 -30
  42. data/doc/GQLi/EnumValue.html +8 -8
  43. data/doc/GQLi/Fragment.html +8 -8
  44. data/doc/GQLi/Github.html +6 -6
  45. data/doc/GQLi/Introspection.html +46 -48
  46. data/doc/GQLi/Mutation.html +390 -0
  47. data/doc/GQLi/Node.html +8 -8
  48. data/doc/GQLi/Query.html +6 -6
  49. data/doc/GQLi/Response.html +87 -13
  50. data/doc/GQLi/Subscription.html +390 -0
  51. data/doc/GQLi/Validation.html +20 -20
  52. data/doc/GQLi.html +9 -9
  53. data/doc/_index.html +37 -7
  54. data/doc/class_list.html +3 -3
  55. data/doc/css/style.css +3 -2
  56. data/doc/file.CHANGELOG.html +43 -13
  57. data/doc/file.LICENSE.html +6 -6
  58. data/doc/file.README.html +31 -84
  59. data/doc/file_list.html +2 -2
  60. data/doc/frames.html +2 -2
  61. data/doc/index.html +31 -84
  62. data/doc/js/app.js +25 -3
  63. data/doc/method_list.html +147 -43
  64. data/doc/top-level-namespace.html +6 -6
  65. data/gqli.gemspec +5 -6
  66. data/lib/gqli/client.rb +25 -5
  67. data/lib/gqli/clients/contentful.rb +3 -2
  68. data/lib/gqli/dsl.rb +16 -1
  69. data/lib/gqli/introspection.rb +1 -3
  70. data/lib/gqli/mutation.rb +27 -0
  71. data/lib/gqli/response.rb +15 -2
  72. data/lib/gqli/subscription.rb +1 -1
  73. data/lib/gqli/validation.rb +15 -12
  74. data/lib/gqli/version.rb +1 -1
  75. data/spec/fixtures/vcr_cassettes/client.yml +98 -27
  76. data/spec/fixtures/vcr_cassettes/mutation_client.yml +4364 -0
  77. data/spec/lib/gqli/client_spec.rb +53 -0
  78. data/spec/lib/gqli/dsl_spec.rb +72 -2
  79. data/spec/lib/gqli/introspection_spec.rb +54 -0
  80. data/spec/lib/gqli/response_spec.rb +51 -0
  81. metadata +64 -73
  82. data/coverage/assets/0.10.2/application.css +0 -799
  83. data/coverage/assets/0.10.2/application.js +0 -1707
data/doc/method_list.html CHANGED
@@ -4,9 +4,9 @@
4
4
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
5
  <meta charset="utf-8" />
6
6
 
7
- <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
8
8
 
9
- <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
10
10
 
11
11
 
12
12
 
@@ -76,6 +76,22 @@
76
76
  </li>
77
77
 
78
78
 
79
+ <li class="odd ">
80
+ <div class="item">
81
+ <span class='object_link'><a href="GQLi/Subscription.html#__execute-instance_method" title="GQLi::Subscription#__execute (method)">#__execute</a></span>
82
+ <small>GQLi::Subscription</small>
83
+ </div>
84
+ </li>
85
+
86
+
87
+ <li class="even ">
88
+ <div class="item">
89
+ <span class='object_link'><a href="GQLi/Mutation.html#__execute-instance_method" title="GQLi::Mutation#__execute (method)">#__execute</a></span>
90
+ <small>GQLi::Mutation</small>
91
+ </div>
92
+ </li>
93
+
94
+
79
95
  <li class="odd ">
80
96
  <div class="item">
81
97
  <span class='object_link'><a href="GQLi/Base.html#__name-instance_method" title="GQLi::Base#__name (method)">#__name</a></span>
@@ -150,7 +166,7 @@
150
166
 
151
167
  <li class="even ">
152
168
  <div class="item">
153
- <span class='object_link'><a href="GQLi/DSL.html#enum-class_method" title="GQLi::DSL.enum (method)">enum</a></span>
169
+ <span class='object_link'><a href="GQLi/DSL.html#enum-instance_method" title="GQLi::DSL#enum (method)">#enum</a></span>
154
170
  <small>GQLi::DSL</small>
155
171
  </div>
156
172
  </li>
@@ -158,13 +174,21 @@
158
174
 
159
175
  <li class="odd ">
160
176
  <div class="item">
161
- <span class='object_link'><a href="GQLi/DSL.html#enum-instance_method" title="GQLi::DSL#enum (method)">#enum</a></span>
177
+ <span class='object_link'><a href="GQLi/DSL.html#enum-class_method" title="GQLi::DSL.enum (method)">enum</a></span>
162
178
  <small>GQLi::DSL</small>
163
179
  </div>
164
180
  </li>
165
181
 
166
182
 
167
183
  <li class="even ">
184
+ <div class="item">
185
+ <span class='object_link'><a href="GQLi/Response.html#errors-instance_method" title="GQLi::Response#errors (method)">#errors</a></span>
186
+ <small>GQLi::Response</small>
187
+ </div>
188
+ </li>
189
+
190
+
191
+ <li class="odd ">
168
192
  <div class="item">
169
193
  <span class='object_link'><a href="GQLi/Validation.html#errors-instance_method" title="GQLi::Validation#errors (method)">#errors</a></span>
170
194
  <small>GQLi::Validation</small>
@@ -172,7 +196,7 @@
172
196
  </li>
173
197
 
174
198
 
175
- <li class="odd ">
199
+ <li class="even ">
176
200
  <div class="item">
177
201
  <span class='object_link'><a href="GQLi/Client.html#execute-instance_method" title="GQLi::Client#execute (method)">#execute</a></span>
178
202
  <small>GQLi::Client</small>
@@ -180,7 +204,7 @@
180
204
  </li>
181
205
 
182
206
 
183
- <li class="even ">
207
+ <li class="odd ">
184
208
  <div class="item">
185
209
  <span class='object_link'><a href="GQLi/Client.html#execute!-instance_method" title="GQLi::Client#execute! (method)">#execute!</a></span>
186
210
  <small>GQLi::Client</small>
@@ -188,7 +212,7 @@
188
212
  </li>
189
213
 
190
214
 
191
- <li class="odd ">
215
+ <li class="even ">
192
216
  <div class="item">
193
217
  <span class='object_link'><a href="GQLi/DSL.html#fragment-class_method" title="GQLi::DSL.fragment (method)">fragment</a></span>
194
218
  <small>GQLi::DSL</small>
@@ -196,7 +220,7 @@
196
220
  </li>
197
221
 
198
222
 
199
- <li class="even ">
223
+ <li class="odd ">
200
224
  <div class="item">
201
225
  <span class='object_link'><a href="GQLi/DSL.html#fragment-instance_method" title="GQLi::DSL#fragment (method)">#fragment</a></span>
202
226
  <small>GQLi::DSL</small>
@@ -204,7 +228,7 @@
204
228
  </li>
205
229
 
206
230
 
207
- <li class="odd ">
231
+ <li class="even ">
208
232
  <div class="item">
209
233
  <span class='object_link'><a href="GQLi/Client.html#headers-instance_method" title="GQLi::Client#headers (method)">#headers</a></span>
210
234
  <small>GQLi::Client</small>
@@ -212,26 +236,34 @@
212
236
  </li>
213
237
 
214
238
 
239
+ <li class="odd ">
240
+ <div class="item">
241
+ <span class='object_link'><a href="GQLi/Client.html#initialize-instance_method" title="GQLi::Client#initialize (method)">#initialize</a></span>
242
+ <small>GQLi::Client</small>
243
+ </div>
244
+ </li>
245
+
246
+
215
247
  <li class="even ">
216
248
  <div class="item">
217
- <span class='object_link'><a href="GQLi/Response.html#initialize-instance_method" title="GQLi::Response#initialize (method)">#initialize</a></span>
218
- <small>GQLi::Response</small>
249
+ <span class='object_link'><a href="GQLi/Introspection.html#initialize-instance_method" title="GQLi::Introspection#initialize (method)">#initialize</a></span>
250
+ <small>GQLi::Introspection</small>
219
251
  </div>
220
252
  </li>
221
253
 
222
254
 
223
255
  <li class="odd ">
224
256
  <div class="item">
225
- <span class='object_link'><a href="GQLi/Node.html#initialize-instance_method" title="GQLi::Node#initialize (method)">#initialize</a></span>
226
- <small>GQLi::Node</small>
257
+ <span class='object_link'><a href="GQLi/Fragment.html#initialize-instance_method" title="GQLi::Fragment#initialize (method)">#initialize</a></span>
258
+ <small>GQLi::Fragment</small>
227
259
  </div>
228
260
  </li>
229
261
 
230
262
 
231
263
  <li class="even ">
232
264
  <div class="item">
233
- <span class='object_link'><a href="GQLi/Client.html#initialize-instance_method" title="GQLi::Client#initialize (method)">#initialize</a></span>
234
- <small>GQLi::Client</small>
265
+ <span class='object_link'><a href="GQLi/Node.html#initialize-instance_method" title="GQLi::Node#initialize (method)">#initialize</a></span>
266
+ <small>GQLi::Node</small>
235
267
  </div>
236
268
  </li>
237
269
 
@@ -246,8 +278,8 @@
246
278
 
247
279
  <li class="even ">
248
280
  <div class="item">
249
- <span class='object_link'><a href="GQLi/Fragment.html#initialize-instance_method" title="GQLi::Fragment#initialize (method)">#initialize</a></span>
250
- <small>GQLi::Fragment</small>
281
+ <span class='object_link'><a href="GQLi/Validation.html#initialize-instance_method" title="GQLi::Validation#initialize (method)">#initialize</a></span>
282
+ <small>GQLi::Validation</small>
251
283
  </div>
252
284
  </li>
253
285
 
@@ -262,21 +294,29 @@
262
294
 
263
295
  <li class="even ">
264
296
  <div class="item">
265
- <span class='object_link'><a href="GQLi/Validation.html#initialize-instance_method" title="GQLi::Validation#initialize (method)">#initialize</a></span>
266
- <small>GQLi::Validation</small>
297
+ <span class='object_link'><a href="GQLi/Response.html#initialize-instance_method" title="GQLi::Response#initialize (method)">#initialize</a></span>
298
+ <small>GQLi::Response</small>
267
299
  </div>
268
300
  </li>
269
301
 
270
302
 
271
303
  <li class="odd ">
272
304
  <div class="item">
273
- <span class='object_link'><a href="GQLi/Introspection.html#initialize-instance_method" title="GQLi::Introspection#initialize (method)">#initialize</a></span>
274
- <small>GQLi::Introspection</small>
305
+ <span class='object_link'><a href="GQLi/DSL.html#mutation-class_method" title="GQLi::DSL.mutation (method)">mutation</a></span>
306
+ <small>GQLi::DSL</small>
275
307
  </div>
276
308
  </li>
277
309
 
278
310
 
279
311
  <li class="even ">
312
+ <div class="item">
313
+ <span class='object_link'><a href="GQLi/DSL.html#mutation-instance_method" title="GQLi::DSL#mutation (method)">#mutation</a></span>
314
+ <small>GQLi::DSL</small>
315
+ </div>
316
+ </li>
317
+
318
+
319
+ <li class="odd ">
280
320
  <div class="item">
281
321
  <span class='object_link'><a href="GQLi/Introspection.html#mutation_type-instance_method" title="GQLi::Introspection#mutation_type (method)">#mutation_type</a></span>
282
322
  <small>GQLi::Introspection</small>
@@ -284,6 +324,14 @@
284
324
  </li>
285
325
 
286
326
 
327
+ <li class="even ">
328
+ <div class="item">
329
+ <span class='object_link'><a href="GQLi/Client.html#options-instance_method" title="GQLi::Client#options (method)">#options</a></span>
330
+ <small>GQLi::Client</small>
331
+ </div>
332
+ </li>
333
+
334
+
287
335
  <li class="odd ">
288
336
  <div class="item">
289
337
  <span class='object_link'><a href="GQLi/Client.html#params-instance_method" title="GQLi::Client#params (method)">#params</a></span>
@@ -302,8 +350,8 @@
302
350
 
303
351
  <li class="odd ">
304
352
  <div class="item">
305
- <span class='object_link'><a href="GQLi/Validation.html#query-instance_method" title="GQLi::Validation#query (method)">#query</a></span>
306
- <small>GQLi::Validation</small>
353
+ <span class='object_link'><a href="GQLi/DSL.html#query-class_method" title="GQLi::DSL.query (method)">query</a></span>
354
+ <small>GQLi::DSL</small>
307
355
  </div>
308
356
  </li>
309
357
 
@@ -318,16 +366,32 @@
318
366
 
319
367
  <li class="odd ">
320
368
  <div class="item">
321
- <span class='object_link'><a href="GQLi/DSL.html#query-class_method" title="GQLi::DSL.query (method)">query</a></span>
322
- <small>GQLi::DSL</small>
369
+ <span class='object_link'><a href="GQLi/Introspection.html#query_type-instance_method" title="GQLi::Introspection#query_type (method)">#query_type</a></span>
370
+ <small>GQLi::Introspection</small>
323
371
  </div>
324
372
  </li>
325
373
 
326
374
 
327
375
  <li class="even ">
328
376
  <div class="item">
329
- <span class='object_link'><a href="GQLi/Introspection.html#query_type-instance_method" title="GQLi::Introspection#query_type (method)">#query_type</a></span>
330
- <small>GQLi::Introspection</small>
377
+ <span class='object_link'><a href="GQLi/Client.html#request-instance_method" title="GQLi::Client#request (method)">#request</a></span>
378
+ <small>GQLi::Client</small>
379
+ </div>
380
+ </li>
381
+
382
+
383
+ <li class="odd ">
384
+ <div class="item">
385
+ <span class='object_link'><a href="GQLi/Validation.html#root-instance_method" title="GQLi::Validation#root (method)">#root</a></span>
386
+ <small>GQLi::Validation</small>
387
+ </div>
388
+ </li>
389
+
390
+
391
+ <li class="even ">
392
+ <div class="item">
393
+ <span class='object_link'><a href="GQLi/Client.html#schema-instance_method" title="GQLi::Client#schema (method)">#schema</a></span>
394
+ <small>GQLi::Client</small>
331
395
  </div>
332
396
  </li>
333
397
 
@@ -350,24 +414,24 @@
350
414
 
351
415
  <li class="odd ">
352
416
  <div class="item">
353
- <span class='object_link'><a href="GQLi/Client.html#schema-instance_method" title="GQLi::Client#schema (method)">#schema</a></span>
354
- <small>GQLi::Client</small>
417
+ <span class='object_link'><a href="GQLi/DSL.html#subscription-instance_method" title="GQLi::DSL#subscription (method)">#subscription</a></span>
418
+ <small>GQLi::DSL</small>
355
419
  </div>
356
420
  </li>
357
421
 
358
422
 
359
423
  <li class="even ">
360
424
  <div class="item">
361
- <span class='object_link'><a href="GQLi/Introspection.html#subscription_type-instance_method" title="GQLi::Introspection#subscription_type (method)">#subscription_type</a></span>
362
- <small>GQLi::Introspection</small>
425
+ <span class='object_link'><a href="GQLi/DSL.html#subscription-class_method" title="GQLi::DSL.subscription (method)">subscription</a></span>
426
+ <small>GQLi::DSL</small>
363
427
  </div>
364
428
  </li>
365
429
 
366
430
 
367
431
  <li class="odd ">
368
432
  <div class="item">
369
- <span class='object_link'><a href="GQLi/Query.html#to_gql-instance_method" title="GQLi::Query#to_gql (method)">#to_gql</a></span>
370
- <small>GQLi::Query</small>
433
+ <span class='object_link'><a href="GQLi/Introspection.html#subscription_type-instance_method" title="GQLi::Introspection#subscription_type (method)">#subscription_type</a></span>
434
+ <small>GQLi::Introspection</small>
371
435
  </div>
372
436
  </li>
373
437
 
@@ -382,21 +446,45 @@
382
446
 
383
447
  <li class="odd ">
384
448
  <div class="item">
385
- <span class='object_link'><a href="GQLi/Node.html#to_gql-instance_method" title="GQLi::Node#to_gql (method)">#to_gql</a></span>
386
- <small>GQLi::Node</small>
449
+ <span class='object_link'><a href="GQLi/Mutation.html#to_gql-instance_method" title="GQLi::Mutation#to_gql (method)">#to_gql</a></span>
450
+ <small>GQLi::Mutation</small>
387
451
  </div>
388
452
  </li>
389
453
 
390
454
 
391
455
  <li class="even ">
392
456
  <div class="item">
393
- <span class='object_link'><a href="GQLi/Query.html#to_s-instance_method" title="GQLi::Query#to_s (method)">#to_s</a></span>
457
+ <span class='object_link'><a href="GQLi/Subscription.html#to_gql-instance_method" title="GQLi::Subscription#to_gql (method)">#to_gql</a></span>
458
+ <small>GQLi::Subscription</small>
459
+ </div>
460
+ </li>
461
+
462
+
463
+ <li class="odd ">
464
+ <div class="item">
465
+ <span class='object_link'><a href="GQLi/Query.html#to_gql-instance_method" title="GQLi::Query#to_gql (method)">#to_gql</a></span>
394
466
  <small>GQLi::Query</small>
395
467
  </div>
396
468
  </li>
397
469
 
398
470
 
471
+ <li class="even ">
472
+ <div class="item">
473
+ <span class='object_link'><a href="GQLi/Node.html#to_gql-instance_method" title="GQLi::Node#to_gql (method)">#to_gql</a></span>
474
+ <small>GQLi::Node</small>
475
+ </div>
476
+ </li>
477
+
478
+
399
479
  <li class="odd ">
480
+ <div class="item">
481
+ <span class='object_link'><a href="GQLi/Subscription.html#to_s-instance_method" title="GQLi::Subscription#to_s (method)">#to_s</a></span>
482
+ <small>GQLi::Subscription</small>
483
+ </div>
484
+ </li>
485
+
486
+
487
+ <li class="even ">
400
488
  <div class="item">
401
489
  <span class='object_link'><a href="GQLi/EnumValue.html#to_s-instance_method" title="GQLi::EnumValue#to_s (method)">#to_s</a></span>
402
490
  <small>GQLi::EnumValue</small>
@@ -404,25 +492,33 @@
404
492
  </li>
405
493
 
406
494
 
495
+ <li class="odd ">
496
+ <div class="item">
497
+ <span class='object_link'><a href="GQLi/Mutation.html#to_s-instance_method" title="GQLi::Mutation#to_s (method)">#to_s</a></span>
498
+ <small>GQLi::Mutation</small>
499
+ </div>
500
+ </li>
501
+
502
+
407
503
  <li class="even ">
408
504
  <div class="item">
409
- <span class='object_link'><a href="GQLi/Introspection.html#types-instance_method" title="GQLi::Introspection#types (method)">#types</a></span>
410
- <small>GQLi::Introspection</small>
505
+ <span class='object_link'><a href="GQLi/Query.html#to_s-instance_method" title="GQLi::Query#to_s (method)">#to_s</a></span>
506
+ <small>GQLi::Query</small>
411
507
  </div>
412
508
  </li>
413
509
 
414
510
 
415
511
  <li class="odd ">
416
512
  <div class="item">
417
- <span class='object_link'><a href="GQLi/Client.html#url-instance_method" title="GQLi::Client#url (method)">#url</a></span>
418
- <small>GQLi::Client</small>
513
+ <span class='object_link'><a href="GQLi/Introspection.html#types-instance_method" title="GQLi::Introspection#types (method)">#types</a></span>
514
+ <small>GQLi::Introspection</small>
419
515
  </div>
420
516
  </li>
421
517
 
422
518
 
423
519
  <li class="even ">
424
520
  <div class="item">
425
- <span class='object_link'><a href="GQLi/Client.html#valid%3F-instance_method" title="GQLi::Client#valid? (method)">#valid?</a></span>
521
+ <span class='object_link'><a href="GQLi/Client.html#url-instance_method" title="GQLi::Client#url (method)">#url</a></span>
426
522
  <small>GQLi::Client</small>
427
523
  </div>
428
524
  </li>
@@ -445,6 +541,14 @@
445
541
 
446
542
 
447
543
  <li class="odd ">
544
+ <div class="item">
545
+ <span class='object_link'><a href="GQLi/Client.html#valid%3F-instance_method" title="GQLi::Client#valid? (method)">#valid?</a></span>
546
+ <small>GQLi::Client</small>
547
+ </div>
548
+ </li>
549
+
550
+
551
+ <li class="even ">
448
552
  <div class="item">
449
553
  <span class='object_link'><a href="GQLi/Introspection.html#validate-instance_method" title="GQLi::Introspection#validate (method)">#validate</a></span>
450
554
  <small>GQLi::Introspection</small>
@@ -452,7 +556,7 @@
452
556
  </li>
453
557
 
454
558
 
455
- <li class="even ">
559
+ <li class="odd ">
456
560
  <div class="item">
457
561
  <span class='object_link'><a href="GQLi/Client.html#validate_query-instance_method" title="GQLi::Client#validate_query (method)">#validate_query</a></span>
458
562
  <small>GQLi::Client</small>
@@ -460,7 +564,7 @@
460
564
  </li>
461
565
 
462
566
 
463
- <li class="odd ">
567
+ <li class="even ">
464
568
  <div class="item">
465
569
  <span class='object_link'><a href="GQLi/EnumValue.html#value-instance_method" title="GQLi::EnumValue#value (method)">#value</a></span>
466
570
  <small>GQLi::EnumValue</small>
@@ -6,15 +6,15 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.9.16
9
+ &mdash; Documentation by YARD 0.9.27
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
14
 
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
16
 
17
- <script type="text/javascript" charset="utf-8">
17
+ <script type="text/javascript">
18
18
  pathId = "";
19
19
  relpath = '';
20
20
  </script>
@@ -100,9 +100,9 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Sat Feb 16 22:53:59 2019 by
103
+ Generated on Mon Jan 3 17:37:12 2022 by
104
104
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
- 0.9.16 (ruby-2.5.3).
105
+ 0.9.27 (ruby-3.0.3).
106
106
  </div>
107
107
 
108
108
  </div>
data/gqli.gemspec CHANGED
@@ -15,12 +15,11 @@ Gem::Specification.new do |gem|
15
15
  gem.test_files = gem.files.grep(%r{^spec/})
16
16
  gem.require_paths = ['lib']
17
17
 
18
- gem.add_dependency 'http', '> 0.8', '< 3.0'
19
- gem.add_dependency 'hashie', '~> 3.0'
18
+ gem.add_dependency 'hashie', '> 3.0'
19
+ gem.add_dependency 'http', '> 0.8', '< 6.0'
20
20
  gem.add_dependency 'multi_json', '~> 1'
21
21
 
22
- gem.add_development_dependency 'bundler', '~> 1.5'
23
- gem.add_development_dependency 'rake', '< 11.0'
22
+ gem.add_development_dependency 'rake'
24
23
  gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
25
24
 
26
25
  gem.add_development_dependency 'guard'
@@ -30,8 +29,8 @@ Gem::Specification.new do |gem|
30
29
  gem.add_development_dependency 'rubocop', '~> 0.49.1'
31
30
  gem.add_development_dependency 'rspec', '~> 3'
32
31
  gem.add_development_dependency 'rr'
33
- gem.add_development_dependency 'vcr'
32
+ gem.add_development_dependency 'vcr', '~> 4.0'
34
33
  gem.add_development_dependency 'simplecov'
35
- gem.add_development_dependency 'webmock', '~> 1', '>= 1.17.3'
34
+ gem.add_development_dependency 'webmock', '~> 3.5'
36
35
  gem.add_development_dependency 'tins', '~> 1.6.0'
37
36
  end
data/lib/gqli/client.rb CHANGED
@@ -9,13 +9,17 @@ require_relative './version'
9
9
  module GQLi
10
10
  # GraphQL HTTP Client
11
11
  class Client
12
- attr_reader :url, :params, :headers, :validate_query, :schema
12
+ attr_reader :url, :params, :headers, :validate_query, :schema, :options
13
13
 
14
- def initialize(url, params: {}, headers: {}, validate_query: true)
14
+ def initialize(url, params: {}, headers: {}, validate_query: true, options: {})
15
15
  @url = url
16
16
  @params = params
17
17
  @headers = headers
18
18
  @validate_query = validate_query
19
+ @options = options
20
+ @options[:read_timeout] ||= 60
21
+ @options[:write_timeout] ||= 60
22
+ @options[:connect_timeout] ||= 60
19
23
 
20
24
  @schema = Introspection.new(self) if validate_query
21
25
  end
@@ -34,13 +38,15 @@ module GQLi
34
38
  # Executres a query
35
39
  # Ignores validations
36
40
  def execute!(query)
37
- http_response = HTTP.headers(request_headers).post(@url, params: @params, json: { query: query.to_gql })
41
+ http_response = request.post(@url, params: @params, json: { query: query.to_gql })
38
42
 
39
43
  fail "Error: #{http_response.reason}\nBody: #{http_response.body}" if http_response.status >= 300
40
44
 
41
- data = JSON.parse(http_response.to_s)['data']
45
+ parsed_response = JSON.parse(http_response.to_s)
46
+ data = parsed_response['data']
47
+ errors = parsed_response['errors']
42
48
 
43
- Response.new(data, query)
49
+ Response.new(data, errors, query)
44
50
  end
45
51
 
46
52
  # Validates a query against the schema
@@ -50,6 +56,12 @@ module GQLi
50
56
  schema.valid?(query)
51
57
  end
52
58
 
59
+ # Executes the actual request
60
+ # @private
61
+ def request
62
+ HTTP.headers(request_headers).timeout(timeout_options)
63
+ end
64
+
53
65
  protected
54
66
 
55
67
  def validation_error_message(validation)
@@ -67,5 +79,13 @@ module GQLi
67
79
  user_agent: "gqli.rb/#{VERSION}; http.rb/#{HTTP::VERSION}"
68
80
  }.merge(@headers)
69
81
  end
82
+
83
+ def timeout_options
84
+ {
85
+ write: options[:write_timeout],
86
+ connect: options[:connect_timeout],
87
+ read: options[:read_timeout]
88
+ }
89
+ end
70
90
  end
71
91
  end
@@ -4,7 +4,7 @@ module GQLi
4
4
  # Module for creating a Contentful GraphQL client
5
5
  module Contentful
6
6
  # Creates a Contentful GraphQL client
7
- def self.create(space, access_token, environment: nil, validate_query: true)
7
+ def self.create(space, access_token, environment: nil, validate_query: true, options: {})
8
8
  api_url = "https://graphql.contentful.com/content/v1/spaces/#{space}"
9
9
  api_url += "/environments/#{environment}" unless environment.nil?
10
10
 
@@ -13,7 +13,8 @@ module GQLi
13
13
  headers: {
14
14
  'Authorization' => "Bearer #{access_token}"
15
15
  },
16
- validate_query: validate_query
16
+ validate_query: validate_query,
17
+ options: options
17
18
  )
18
19
  end
19
20
  end
data/lib/gqli/dsl.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative './query'
4
+ require_relative './mutation'
4
5
  require_relative './subscription'
5
6
  require_relative './fragment'
6
7
  require_relative './enum_value'
@@ -22,6 +23,13 @@ module GQLi
22
23
  Subscription.new(name, &block)
23
24
  end
24
25
 
26
+ # Creates a Mutation object
27
+ #
28
+ # Can be used at a class level
29
+ def self.mutation(name = nil, &block)
30
+ Mutation.new(name, &block)
31
+ end
32
+
25
33
  # Creates a Fragment object
26
34
  #
27
35
  # Can be used at a class level
@@ -43,9 +51,16 @@ module GQLi
43
51
  Query.new(name, &block)
44
52
  end
45
53
 
54
+ # Creates a Mutation object
55
+ #
56
+ # Can be used at a instance level
57
+ def mutation(name = nil, &block)
58
+ Mutation.new(name, &block)
59
+ end
60
+
46
61
  # Creates a Subscription object
47
62
  #
48
- # Can be used at a class level
63
+ # Can be used at a instance level
49
64
  def subscription(name = nil, &block)
50
65
  Subscription.new(name, &block)
51
66
  end
@@ -69,9 +69,7 @@ module GQLi
69
69
  name
70
70
  description
71
71
  args { ___ InputValue }
72
- onOperation
73
- onFragment
74
- onField
72
+ locations
75
73
  }
76
74
  }
77
75
  }
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GQLi
4
+ # Mutation node
5
+ class Mutation < Base
6
+ # Serializes to a GraphQL string
7
+ def to_gql
8
+ result = <<~GQL
9
+ mutation #{__name ? __name + ' ' : ''}{
10
+ #{__nodes.map(&:to_gql).join("\n")}
11
+ }
12
+ GQL
13
+
14
+ result.lstrip
15
+ end
16
+
17
+ # Delegates itself to the client to be executed
18
+ def __execute(client)
19
+ client.execute(self)
20
+ end
21
+
22
+ # Serializes to a GraphQL string
23
+ def to_s
24
+ to_gql
25
+ end
26
+ end
27
+ end
data/lib/gqli/response.rb CHANGED
@@ -5,11 +5,24 @@ require 'hashie/mash'
5
5
  module GQLi
6
6
  # Response object wrapper
7
7
  class Response
8
- attr_reader :data, :query
8
+ attr_reader :data, :errors, :query
9
9
 
10
- def initialize(data, query)
10
+ def initialize(data, errors, query)
11
11
  @data = Hashie::Mash.new(data)
12
+ @errors = parse_errors(errors)
12
13
  @query = query
13
14
  end
15
+
16
+ private
17
+
18
+ # Accepts Hash or Array of errors and converts them to Hashie::Mash instances.
19
+ # Recursively calls #parse_errors with items if array.
20
+ # Returns nil if nil is passed.
21
+ def parse_errors(errors)
22
+ return unless errors
23
+ return errors.map { |e| parse_errors(e) } if errors.is_a?(Array)
24
+
25
+ Hashie::Mash.new(errors)
26
+ end
14
27
  end
15
28
  end