graphql-api 0.1.6 → 0.2.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/README.md +6 -0
- data/lib/graphql/api/resolvers/command_mutation.rb +2 -2
- data/lib/graphql/api/resolvers/model_create_mutation.rb +2 -2
- data/lib/graphql/api/resolvers/model_delete_mutation.rb +2 -2
- data/lib/graphql/api/resolvers/model_update_mutation.rb +3 -3
- data/lib/graphql/api/schema.rb +2 -1
- data/lib/graphql/api/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78d5c46099668e597f16616544d36ac0dff34339
|
|
4
|
+
data.tar.gz: f1405bf7716756f4cb334ed35e521e5a518bdd85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f3191a3bc4cde72e164a5f63aa57393eb9a6fd9df9c272912b75a817c38690749b61ee535818041f0d7de4a4af3875c7ea1c5aa52aebf1e79ec51ac1dd04385a
|
|
7
|
+
data.tar.gz: 7127aee62913e05b04a90f48d61605b15dc9c162323affd55c1eb4bca9abb74982d1e7cf3f5af54a60853b3e7d72b566b9ca5a606a73de804fad6329b08d4622
|
data/README.md
CHANGED
|
@@ -3,6 +3,12 @@ GraphQL-Api is an opinionated Graphql framework for Rails that supports
|
|
|
3
3
|
auto generating queries based on Active Record models and plain Ruby
|
|
4
4
|
objects.
|
|
5
5
|
|
|
6
|
+
## Status
|
|
7
|
+
|
|
8
|
+
This project is an active work in progress. The API is currently being refined
|
|
9
|
+
and subject to change. Contributions are more than welcome! Once the project hits
|
|
10
|
+
a 1.0 release the API should be considered stable.
|
|
11
|
+
|
|
6
12
|
## Example
|
|
7
13
|
|
|
8
14
|
Given the following model structure:
|
|
@@ -7,13 +7,13 @@ module GraphQL::Api
|
|
|
7
7
|
@policy_class = "#{model.name}Policy".safe_constantize
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def call(
|
|
10
|
+
def call(obj, args, ctx)
|
|
11
11
|
if @policy_class
|
|
12
12
|
policy = @policy_class.new(ctx, nil)
|
|
13
13
|
return policy.unauthorized! unless policy.create?
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
item = @model.create!(
|
|
16
|
+
item = @model.create!(args.to_h)
|
|
17
17
|
{key => item}
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -7,8 +7,8 @@ module GraphQL::Api
|
|
|
7
7
|
@policy_class = "#{model.name}Policy".safe_constantize
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def call(
|
|
11
|
-
item = @model.find(
|
|
10
|
+
def call(obj, args, ctx)
|
|
11
|
+
item = @model.find(args[:id])
|
|
12
12
|
|
|
13
13
|
if @policy_class
|
|
14
14
|
policy = @policy_class.new(ctx, item)
|
|
@@ -7,15 +7,15 @@ module GraphQL::Api
|
|
|
7
7
|
@policy_class = "#{model.name}Policy".safe_constantize
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
def call(
|
|
11
|
-
item = @model.find(
|
|
10
|
+
def call(obj, args, ctx)
|
|
11
|
+
item = @model.find(args[:id])
|
|
12
12
|
|
|
13
13
|
if @policy_class
|
|
14
14
|
policy = @policy_class.new(ctx, item)
|
|
15
15
|
return policy.unauthorized! unless policy.destroy?
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
item.update!(
|
|
18
|
+
item.update!(args.to_h)
|
|
19
19
|
{key => item}
|
|
20
20
|
end
|
|
21
21
|
|
data/lib/graphql/api/schema.rb
CHANGED
|
@@ -82,9 +82,10 @@ module GraphQL::Api
|
|
|
82
82
|
|
|
83
83
|
def create_command_type(object_type, action)
|
|
84
84
|
object_types = @types
|
|
85
|
+
prefix = action == :perform ? '' : action.capitalize
|
|
85
86
|
|
|
86
87
|
GraphQL::Relay::Mutation.define do
|
|
87
|
-
name object_type.name
|
|
88
|
+
name "#{prefix}#{object_type.name}"
|
|
88
89
|
description "Command #{object_type.name} #{action}"
|
|
89
90
|
|
|
90
91
|
object_type.inputs.each do |input, type|
|
data/lib/graphql/api/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: graphql-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Colin Walker
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-01-
|
|
11
|
+
date: 2017-01-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -28,16 +28,16 @@ dependencies:
|
|
|
28
28
|
name: graphql
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 1.4.1
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: 1.4.1
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: sqlite3
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|