graphql-mutable_type 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile.lock +5 -5
- data/graphql-mutable_type.gemspec +4 -3
- data/lib/graphql/define/mutation_fields.rb +28 -0
- data/lib/graphql/mutable_type/version.rb +1 -1
- data/lib/graphql/mutable_type.rb +3 -3
- data/spec/graphql/mutable_type_spec.rb +21 -22
- metadata +7 -7
- data/lib/graphql/mutable_type/defined_by_config.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89fb3a85369538a3251f2911be4bea0d23ab20c4
|
4
|
+
data.tar.gz: 516603617ade7b03087786c9ccd82499b7b0c995
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4574fc437dda520bb062a1f5f8595ee61170848ba37a37aa89ee5cbb0addad425f41750bb68d4700ee5a245fd8c53118d04b37c60002055d23fa73f8084151e4
|
7
|
+
data.tar.gz: 295245c765450776abbf4825990c26bece7bb204bc34e9606963cff8bc8065c45c89769cb07ed0196844cc7d6925a8a3c5debbb644a3391c294d5d7dd42cccba
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphql-mutable_type (0.0
|
5
|
-
graphql (~> 0.
|
4
|
+
graphql-mutable_type (0.1.0)
|
5
|
+
graphql (~> 0.12.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -19,7 +19,7 @@ GEM
|
|
19
19
|
tins (~> 1.6.0)
|
20
20
|
diff-lcs (1.2.5)
|
21
21
|
docile (1.1.5)
|
22
|
-
graphql (0.
|
22
|
+
graphql (0.12.0)
|
23
23
|
parslet (~> 1.6)
|
24
24
|
json (1.8.3)
|
25
25
|
method_source (0.8.2)
|
@@ -29,7 +29,7 @@ GEM
|
|
29
29
|
coderay (~> 1.1.0)
|
30
30
|
method_source (~> 0.8.1)
|
31
31
|
slop (~> 3.4)
|
32
|
-
rake (
|
32
|
+
rake (11.1.2)
|
33
33
|
rspec (3.4.0)
|
34
34
|
rspec-core (~> 3.4.0)
|
35
35
|
rspec-expectations (~> 3.4.0)
|
@@ -62,7 +62,7 @@ DEPENDENCIES
|
|
62
62
|
coveralls
|
63
63
|
graphql-mutable_type!
|
64
64
|
pry (~> 0.10)
|
65
|
-
rake (~>
|
65
|
+
rake (~> 11.1)
|
66
66
|
rspec (~> 3.4)
|
67
67
|
|
68
68
|
BUNDLED WITH
|
@@ -1,11 +1,12 @@
|
|
1
1
|
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
2
2
|
|
3
3
|
require 'graphql/mutable_type/version'
|
4
|
+
require 'time'
|
4
5
|
|
5
6
|
Gem::Specification.new do |gem|
|
6
7
|
gem.name = 'graphql-mutable_type'
|
7
8
|
gem.version = GraphQL::MUTABLE_TYPE_VERSION
|
8
|
-
gem.date =
|
9
|
+
gem.date = Time.parse(`git log -1 --format=%cd`).utc
|
9
10
|
gem.summary = 'An Object Type that may have mutation queries.'
|
10
11
|
gem.description = 'An Object Type that may have mutation queries.'
|
11
12
|
gem.homepage = 'https://github.com/TapasTech/graphql-mutable_type'
|
@@ -19,11 +20,11 @@ Gem::Specification.new do |gem|
|
|
19
20
|
gem.files = `git ls-files`.split("\n")
|
20
21
|
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
21
22
|
|
22
|
-
gem.add_dependency 'graphql', '~> 0.
|
23
|
+
gem.add_dependency 'graphql', '~> 0.12.0'
|
23
24
|
|
24
25
|
gem.add_development_dependency 'coveralls'
|
25
26
|
gem.add_development_dependency 'codeclimate-test-reporter', '~>0.4'
|
26
27
|
gem.add_development_dependency 'pry', '~> 0.10'
|
27
28
|
gem.add_development_dependency 'rspec', '~> 3.4'
|
28
|
-
gem.add_development_dependency 'rake', '~>
|
29
|
+
gem.add_development_dependency 'rake', '~> 11.1'
|
29
30
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GraphQL
|
2
|
+
module Define
|
3
|
+
# # Define MutableType by define block
|
4
|
+
module MutationFields
|
5
|
+
def self.call(mutable_type, &block)
|
6
|
+
mutation_type = mutation_type(mutable_type, &block)
|
7
|
+
|
8
|
+
mutable_type.fields['mutation'] = GraphQL::Field.define do
|
9
|
+
name 'mutation'
|
10
|
+
type mutation_type
|
11
|
+
description mutation_type.description
|
12
|
+
|
13
|
+
resolve -> (obj, _args, _cxt) { obj }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private_class_method
|
18
|
+
|
19
|
+
# define nested mutation type
|
20
|
+
def self.mutation_type(mutable_type, &block)
|
21
|
+
m_type = GraphQL::ObjectType.define(&block)
|
22
|
+
m_type.name = "#{mutable_type.name}Mutation"
|
23
|
+
m_type.description = "Mutations of #{mutable_type.description}"
|
24
|
+
m_type
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/graphql/mutable_type.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
require 'graphql/define/mutation_fields'
|
2
|
+
|
1
3
|
module GraphQL
|
2
4
|
# Mutable Type is an extended Object Type that has mutations inside.
|
3
5
|
class MutableType < ObjectType
|
4
|
-
|
6
|
+
accepts_definitions(mutation: GraphQL::Define::MutationFields)
|
5
7
|
|
6
8
|
attr_accessor :mutation
|
7
9
|
end
|
8
10
|
end
|
9
|
-
|
10
|
-
require 'graphql/mutable_type/defined_by_config'
|
11
11
|
# require 'graphql/mutable_type/version'
|
@@ -6,7 +6,6 @@ RSpec.describe GraphQL::MutableType do
|
|
6
6
|
let(:type) { KingType }
|
7
7
|
let(:schema) { FranciaSchema }
|
8
8
|
describe 'define mutable type' do
|
9
|
-
|
10
9
|
let(:mutation) { type.fields['mutation'] }
|
11
10
|
let(:mutation_fields) { mutation.type.fields }
|
12
11
|
|
@@ -26,38 +25,38 @@ RSpec.describe GraphQL::MutableType do
|
|
26
25
|
|
27
26
|
describe 'execute query with mutation' do
|
28
27
|
let(:query) do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
'
|
29
|
+
query {
|
30
|
+
king(id: "k_germany") {
|
31
|
+
id
|
32
|
+
name
|
33
|
+
mutation {
|
34
|
+
rename(name: "Germany") {
|
35
|
+
name
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
37
39
|
}
|
38
|
-
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
40
|
+
'
|
42
41
|
end
|
43
42
|
|
44
43
|
let(:result) do
|
45
44
|
{
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
'data' => {
|
46
|
+
'king' => {
|
47
|
+
'id' => 'k_germany',
|
48
|
+
'name' => 'East Francia',
|
49
|
+
'mutation' => {
|
50
|
+
'rename' => {
|
51
|
+
'name' => 'Germany'
|
53
52
|
}
|
54
53
|
}
|
55
54
|
}
|
56
55
|
}
|
57
|
-
}
|
56
|
+
}
|
58
57
|
end
|
59
58
|
|
60
|
-
it 'renames East Francia to Germany' do
|
59
|
+
it 'renames East Francia to Germany' do
|
61
60
|
expect(schema.execute(query)).to eq(result)
|
62
61
|
end
|
63
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-mutable_type
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karloku Sang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.12.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.12.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: coveralls
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '11.1'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '11.1'
|
97
97
|
description: An Object Type that may have mutation queries.
|
98
98
|
email:
|
99
99
|
- karloku@gmail.com
|
@@ -111,8 +111,8 @@ files:
|
|
111
111
|
- Rakefile
|
112
112
|
- graphql-mutable_type.gemspec
|
113
113
|
- lib/graphql-mutable_type.rb
|
114
|
+
- lib/graphql/define/mutation_fields.rb
|
114
115
|
- lib/graphql/mutable_type.rb
|
115
|
-
- lib/graphql/mutable_type/defined_by_config.rb
|
116
116
|
- lib/graphql/mutable_type/version.rb
|
117
117
|
- spec/graphql/mutable_type_spec.rb
|
118
118
|
- spec/spec_helper.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# Define MutableType by define block
|
2
|
-
class GraphQL::DefinitionHelpers::DefinedByConfig::DefinitionConfig
|
3
|
-
attr_definable :mutation
|
4
|
-
|
5
|
-
def mutation(&block)
|
6
|
-
mutation_type = mutation_type(&block)
|
7
|
-
|
8
|
-
field :mutation do
|
9
|
-
name 'mutation'
|
10
|
-
type mutation_type
|
11
|
-
description mutation_type.description
|
12
|
-
|
13
|
-
resolve -> (obj, _args, _cxt) { obj }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
protected
|
18
|
-
|
19
|
-
# define nested mutation type
|
20
|
-
def mutation_type(&block)
|
21
|
-
@mutation_type ||= begin
|
22
|
-
m_type = GraphQL::ObjectType.define(&block)
|
23
|
-
m_type.name = "#{name}Mutation"
|
24
|
-
m_type.description = "Mutations of #{description}"
|
25
|
-
m_type
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|