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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d066b645b42c6471423c84254b296abe806d8bda
4
- data.tar.gz: dcbc217929b63f258c12c63f392b373acbe6d9dd
3
+ metadata.gz: 78d5c46099668e597f16616544d36ac0dff34339
4
+ data.tar.gz: f1405bf7716756f4cb334ed35e521e5a518bdd85
5
5
  SHA512:
6
- metadata.gz: e3b258f21b2d9d8d5de142659f3334c22d37ec2cf260c448dc6cb166b2461d22bb46ba033a65b2738e5258ee99b4f5e1a0fa4bd82fba6dc9a42d727e1c8718aa
7
- data.tar.gz: eb187d750c57364262bccc79ac107fd331de3c34e51bdc625f1d5003b0a0491863376d57f50051d416c3a3d8ced201ed210f8f348497a87fcbc4507ad2d49908
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,8 +7,8 @@ module GraphQL::Api
7
7
  @action = action
8
8
  end
9
9
 
10
- def call(inputs, ctx)
11
- @command.new(inputs, ctx).send(@action)
10
+ def call(obj, args, ctx)
11
+ @command.new(args, ctx).send(@action)
12
12
  end
13
13
 
14
14
  end
@@ -7,13 +7,13 @@ module GraphQL::Api
7
7
  @policy_class = "#{model.name}Policy".safe_constantize
8
8
  end
9
9
 
10
- def call(inputs, ctx)
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!(inputs.to_h)
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(inputs, ctx)
11
- item = @model.find(inputs[:id])
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(inputs, ctx)
11
- item = @model.find(inputs[:id])
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!(inputs.to_h)
18
+ item.update!(args.to_h)
19
19
  {key => item}
20
20
  end
21
21
 
@@ -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|
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Api
3
- VERSION = '0.1.6'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
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.1.6
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-16 00:00:00.000000000 Z
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: 0.19.0
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: 0.19.0
40
+ version: 1.4.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sqlite3
43
43
  requirement: !ruby/object:Gem::Requirement