gqli 0.6.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/CHANGELOG.md +5 -0
- data/README.md +0 -5
- data/gqli.gemspec +0 -1
- data/lib/gqli/dsl.rb +16 -1
- data/lib/gqli/mutation.rb +27 -0
- data/lib/gqli/subscription.rb +1 -1
- data/lib/gqli/validation.rb +15 -12
- data/lib/gqli/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/mutation_client.yml +4364 -0
- data/spec/lib/gqli/dsl_spec.rb +72 -2
- data/spec/lib/gqli/introspection_spec.rb +54 -0
- metadata +7 -18
data/spec/lib/gqli/dsl_spec.rb
CHANGED
@@ -37,6 +37,43 @@ describe GQLi::DSL do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
describe '::mutation' do
|
41
|
+
it 'can create a mutation without name' do
|
42
|
+
mutation = subject.mutation {
|
43
|
+
addFoo(name: 'bar') {
|
44
|
+
name
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
expect(mutation).to be_a GQLi::Mutation
|
49
|
+
expect(mutation.to_gql).to eq <<~GRAPHQL
|
50
|
+
mutation {
|
51
|
+
addFoo(name: "bar") {
|
52
|
+
name
|
53
|
+
}
|
54
|
+
}
|
55
|
+
GRAPHQL
|
56
|
+
expect(mutation.to_gql).to eq mutation.to_s
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'can create a query with a name' do
|
60
|
+
mutation = subject.mutation('AddFoo') {
|
61
|
+
addFoo(name: 'bar') {
|
62
|
+
name
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
expect(mutation).to be_a GQLi::Mutation
|
67
|
+
expect(mutation.to_gql).to eq <<~GRAPHQL
|
68
|
+
mutation AddFoo {
|
69
|
+
addFoo(name: "bar") {
|
70
|
+
name
|
71
|
+
}
|
72
|
+
}
|
73
|
+
GRAPHQL
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
40
77
|
describe '::subscription' do
|
41
78
|
it 'can create a subscription without name' do
|
42
79
|
subscription = subject.subscription {
|
@@ -122,11 +159,44 @@ describe GQLi::DSL do
|
|
122
159
|
end
|
123
160
|
end
|
124
161
|
|
162
|
+
describe '#mutation does the same as ::mutation' do
|
163
|
+
it 'can create a mutation without name' do
|
164
|
+
mutation = subject.mutation {
|
165
|
+
addFoo(name: 'bar') {
|
166
|
+
name
|
167
|
+
}
|
168
|
+
}
|
125
169
|
|
126
|
-
|
170
|
+
expect(mutation).to be_a GQLi::Mutation
|
171
|
+
expect(mutation.to_gql).to eq <<~GRAPHQL
|
172
|
+
mutation {
|
173
|
+
addFoo(name: "bar") {
|
174
|
+
name
|
175
|
+
}
|
176
|
+
}
|
177
|
+
GRAPHQL
|
178
|
+
expect(mutation.to_gql).to eq mutation.to_s
|
179
|
+
end
|
127
180
|
|
128
|
-
|
181
|
+
it 'can create a query with a name' do
|
182
|
+
mutation = subject.mutation('AddFoo') {
|
183
|
+
addFoo(name: 'bar') {
|
184
|
+
name
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
expect(mutation).to be_a GQLi::Mutation
|
189
|
+
expect(mutation.to_gql).to eq <<~GRAPHQL
|
190
|
+
mutation AddFoo {
|
191
|
+
addFoo(name: "bar") {
|
192
|
+
name
|
193
|
+
}
|
194
|
+
}
|
195
|
+
GRAPHQL
|
196
|
+
end
|
197
|
+
end
|
129
198
|
|
199
|
+
describe '#subscription does the same as ::subscription' do
|
130
200
|
it 'can create a subscription without name' do
|
131
201
|
subscription = subject.subscription {
|
132
202
|
someField
|
@@ -322,5 +322,59 @@ describe GQLi::Introspection do
|
|
322
322
|
expect(validation.errors.map(&:to_s)).to include("Invalid argument 'else' for directive '@include'")
|
323
323
|
end
|
324
324
|
end
|
325
|
+
|
326
|
+
describe 'mutations' do
|
327
|
+
let(:client) {
|
328
|
+
vcr('mutation_client') {
|
329
|
+
GQLi::Github.create(ENV.fetch('GITHUB_READ_ONLY', '<ACCESS_TOKEN>'))
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
333
|
+
it 'fails for unknown mutation' do
|
334
|
+
mutation = dsl.mutation {
|
335
|
+
foo(bar: 'baz') {
|
336
|
+
bar
|
337
|
+
}
|
338
|
+
}
|
339
|
+
|
340
|
+
validation = subject.validate(mutation)
|
341
|
+
expect(validation.valid?).to be_falsey
|
342
|
+
expect(validation.errors).not_to be_empty
|
343
|
+
expect(validation.errors.map(&:to_s)).to include("Node type not found for 'foo'")
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'fails for unknown arguments' do
|
347
|
+
mutation = dsl.mutation {
|
348
|
+
addComment(foo: 'bar') {
|
349
|
+
subject {
|
350
|
+
id
|
351
|
+
}
|
352
|
+
}
|
353
|
+
}
|
354
|
+
|
355
|
+
validation = subject.validate(mutation)
|
356
|
+
expect(validation.valid?).to be_falsey
|
357
|
+
expect(validation.errors).not_to be_empty
|
358
|
+
expect(validation.errors.map(&:to_s)).to include("Invalid argument 'foo'")
|
359
|
+
end
|
360
|
+
|
361
|
+
it 'true for valid mutation' do
|
362
|
+
mutation = dsl.mutation {
|
363
|
+
addComment(input: {
|
364
|
+
subjectId: 'some subject id',
|
365
|
+
body: 'some subject',
|
366
|
+
clientMutationId: 'some identifier'
|
367
|
+
}) {
|
368
|
+
subject {
|
369
|
+
id
|
370
|
+
}
|
371
|
+
}
|
372
|
+
}
|
373
|
+
|
374
|
+
validation = subject.validate(mutation)
|
375
|
+
expect(validation.valid?).to be_truthy
|
376
|
+
expect(validation.errors).to be_empty
|
377
|
+
end
|
378
|
+
end
|
325
379
|
end
|
326
380
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gqli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contentful GmbH (David Litvak Bruno)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -58,20 +58,6 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '1'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: bundler
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '1.5'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '1.5'
|
75
61
|
- !ruby/object:Gem::Dependency
|
76
62
|
name: rake
|
77
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -316,6 +302,7 @@ files:
|
|
316
302
|
- doc/GQLi/Fragment.html
|
317
303
|
- doc/GQLi/Github.html
|
318
304
|
- doc/GQLi/Introspection.html
|
305
|
+
- doc/GQLi/Mutation.html
|
319
306
|
- doc/GQLi/Node.html
|
320
307
|
- doc/GQLi/Query.html
|
321
308
|
- doc/GQLi/Response.html
|
@@ -348,6 +335,7 @@ files:
|
|
348
335
|
- lib/gqli/enum_value.rb
|
349
336
|
- lib/gqli/fragment.rb
|
350
337
|
- lib/gqli/introspection.rb
|
338
|
+
- lib/gqli/mutation.rb
|
351
339
|
- lib/gqli/node.rb
|
352
340
|
- lib/gqli/query.rb
|
353
341
|
- lib/gqli/response.rb
|
@@ -356,6 +344,7 @@ files:
|
|
356
344
|
- lib/gqli/version.rb
|
357
345
|
- spec/fixtures/vcr_cassettes/catCollection.yml
|
358
346
|
- spec/fixtures/vcr_cassettes/client.yml
|
347
|
+
- spec/fixtures/vcr_cassettes/mutation_client.yml
|
359
348
|
- spec/fixtures/vcr_cassettes/validation_error.yml
|
360
349
|
- spec/lib/gqli/client_spec.rb
|
361
350
|
- spec/lib/gqli/dsl_spec.rb
|
@@ -383,14 +372,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
383
372
|
- !ruby/object:Gem::Version
|
384
373
|
version: '0'
|
385
374
|
requirements: []
|
386
|
-
|
387
|
-
rubygems_version: 2.7.8
|
375
|
+
rubygems_version: 3.0.3
|
388
376
|
signing_key:
|
389
377
|
specification_version: 4
|
390
378
|
summary: GraphQL client for humans
|
391
379
|
test_files:
|
392
380
|
- spec/fixtures/vcr_cassettes/catCollection.yml
|
393
381
|
- spec/fixtures/vcr_cassettes/client.yml
|
382
|
+
- spec/fixtures/vcr_cassettes/mutation_client.yml
|
394
383
|
- spec/fixtures/vcr_cassettes/validation_error.yml
|
395
384
|
- spec/lib/gqli/client_spec.rb
|
396
385
|
- spec/lib/gqli/dsl_spec.rb
|