graphql-rails 0.0.5 → 0.0.6

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: 057f13274ec2fa2303ce2a0e8c9cfc5a9aa9be78
4
- data.tar.gz: 0a33325845d6af90994ad94e164e6f1a56fa14c8
3
+ metadata.gz: 69988931a81e92d26f43e2bae7e2d73b99fbc3bd
4
+ data.tar.gz: 1f9f59e4c2ef955b6c97d09a0b8e851226eac961
5
5
  SHA512:
6
- metadata.gz: 757acce6e810e6b54dfeb031803f1c84579fd5c628f85d95234b4a187e61333f4e08157fc3b2409be9c8868d09b4298d0c1dd57abe3f1bfa01e208a32a4132e2
7
- data.tar.gz: 5b61fef40d244b6971086d7c431d640ed5fbc34c57886e1dd526a69140aee0edb2b77839efe106e82632bd5743d1fcb1aa9bb4cdee09c520d7c03b3390547d9d
6
+ metadata.gz: 74bc93005e853cec5cea9d9fa17b8746bf9427739568f9ed13ed5ccf8d2f54b759e31e6cb6a9d0f32cc178911644e1ca3dcc7539428b4bb88d6c5ece6b1a2073
7
+ data.tar.gz: 318261d7c7f8f34d529b3fb9b49b294b43f0c93fcbeb9d277f7ab91742b832fe7ba2c777f94c74c095da9faff3ac4fbe0f1ca8970654850103b1142400e4828d
@@ -21,10 +21,11 @@ module GraphQL
21
21
  # Define a query operation.
22
22
  # Definitions should have the following form:
23
23
  #
24
- # query :find_cats => [Cat] do
24
+ # query :find_cats => [AnimalInterface] do
25
25
  # description 'This query returns a list of Cat models'
26
26
  # argument :age, Integer, :required
27
27
  # argument :breed, String
28
+ # uses CatType
28
29
  # resolve do
29
30
  # raise 'Too old' if args[:age] > 20
30
31
  # Cat.find(age: args[:age], breed: args[:breed])
@@ -94,6 +95,10 @@ module GraphQL
94
95
  @field.name = Types.to_field_name(name)
95
96
  end
96
97
 
98
+ def uses(type)
99
+ Types.explicit.push Types.resolve(type)
100
+ end
101
+
97
102
  def type(type)
98
103
  @type = type
99
104
  @field.type = Types.resolve(type)
@@ -26,6 +26,7 @@ module GraphQL
26
26
  @schema ||= GraphQL::Schema.new begin
27
27
  TYPES.reduce({
28
28
  max_depth: Rails.config.max_depth,
29
+ types: Types.explicit,
29
30
  }) do |schema, type|
30
31
  fields = @fields[type]
31
32
  unless fields.empty?
@@ -8,6 +8,7 @@ module GraphQL
8
8
  # Clear internal state, probably due to a Rails reload.
9
9
  def clear
10
10
  @types = nil
11
+ @explicit = nil
11
12
  extensions.each do |extension|
12
13
  extension.clear
13
14
  end
@@ -39,6 +40,12 @@ module GraphQL
39
40
  end
40
41
  end
41
42
 
43
+ # Array of types that should be explicitly included in the schema.
44
+ # Useful for ensuring that interface implmentations are included.
45
+ def explicit
46
+ @explicit ||= []
47
+ end
48
+
42
49
  # Lookup an arbitrary object from its GraphQL type name and ID.
43
50
  def lookup(type_name, id)
44
51
  try_extensions(:lookup, type_name, id)
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Rails
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Reggio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-05 00:00:00.000000000 Z
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails