graphql_rails 0.2.3 → 0.2.4

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
  SHA256:
3
- metadata.gz: 20a26e41a67193a0518f0883d6437afccaca80ccfdad3d633e8b75b101f386e5
4
- data.tar.gz: c8731427ea2d337ab81032558b4838a27dfb3e90eca7fdf7b77ccd30df2795fd
3
+ metadata.gz: a8937aa0faf2ed71af96882a43adb9518a454591784d17a1cf22e6c7486a5e90
4
+ data.tar.gz: a4ade684332f5d86f9bfeaf782dfad0a3d9732ef80f731ec071dd0f782ab420e
5
5
  SHA512:
6
- metadata.gz: 04d7c8d897f828cfab27a7f55dc894689dd67fc06512d9f8a9ae2a2f45615fbcdbbebf4b6ed3e3314c514f5ad74aadb0816b11f25dbb36f74a54685e9ed7173c
7
- data.tar.gz: 66a91e7cf1fe70cf4e604aad2660a3907ab65e57f68d40273ced867b2e2623f77ccb7d806c687e4a7dbb35b1b0dd8de93e76e0b33973594ce827a1b1451208dc
6
+ metadata.gz: 3297c4a8ecf0613b6458b10aa9ac19537e4697e95b9d984864e9ff8b28f06d4e2777402340fded49db42d48729f1d3fea6de36037a62069c80da96b0c8a9aec4
7
+ data.tar.gz: 2704a4e4417461da176ef7d3feb8f716b79b6677c3f25a1fcebcb42745461a444289d0b1f267a025f67db81cb8347323b05797d739bdbfedfa0f4f6eb81a65ac
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql_rails (0.2.3)
4
+ graphql_rails (0.2.4)
5
5
  activesupport (>= 4)
6
6
  graphql (~> 1)
7
7
 
@@ -88,12 +88,20 @@ module GraphqlRails
88
88
 
89
89
  def type_by_name
90
90
  TYPE_MAPPING.fetch(inner_type_name) do
91
- raise(
91
+ dynamicly_defined_type || raise(
92
92
  UnknownTypeError,
93
- "Type #{unparsed_type.inspect} is not supported. Supported types are: #{TYPE_MAPPING.keys}"
93
+ "Type #{unparsed_type.inspect} is not supported. Supported scalar types are: #{TYPE_MAPPING.keys}." \
94
+ ' All the classes that includes `GraphqlRails::Model` are also supported as types.'
94
95
  )
95
96
  end
96
97
  end
98
+
99
+ def dynamicly_defined_type
100
+ type_class = inner_type_name.capitalize.safe_constantize
101
+ return unless type_class.respond_to?(:graphql)
102
+
103
+ type_class.graphql.graphql_type
104
+ end
97
105
  end
98
106
  end
99
107
  end
@@ -37,21 +37,20 @@ module GraphqlRails
37
37
  attr_reader :original_name
38
38
 
39
39
  def type_by_attribute_name
40
- type = \
41
- case name
42
- when 'id', /_id\Z/
43
- GraphQL::ID_TYPE
44
- when /\?\Z/
45
- GraphQL::BOOLEAN_TYPE
46
- else
47
- GraphQL::STRING_TYPE
48
- end
49
-
50
- original_name['!'] ? type.to_non_null_type : type
40
+ case name
41
+ when 'id', /_id\Z/
42
+ GraphQL::ID_TYPE
43
+ when /\?\Z/
44
+ GraphQL::BOOLEAN_TYPE
45
+ else
46
+ GraphQL::STRING_TYPE
47
+ end
51
48
  end
52
49
 
53
50
  def parse_type(type)
54
- AttributeTypeParser.new(type).call
51
+ type = AttributeTypeParser.new(type).call
52
+
53
+ original_name['!'] ? type.to_non_null_type : type
55
54
  end
56
55
  end
57
56
  end
@@ -47,7 +47,7 @@ module GraphqlRails
47
47
 
48
48
  def permit_attribute(name, type = nil)
49
49
  field_name = name.to_s.remove(/!\Z/)
50
- attributes[field_name] = Attribute.new(field_name, type)
50
+ attributes[field_name] = Attribute.new(name.to_s, type)
51
51
  end
52
52
  end
53
53
  end
@@ -15,7 +15,8 @@ module GraphqlRails
15
15
  end
16
16
 
17
17
  def name(type_name = nil)
18
- @name ||= type_name
18
+ @name = type_name if type_name
19
+ @name || name_by_class_name
19
20
  end
20
21
 
21
22
  def description(new_description = nil)
@@ -23,21 +24,19 @@ module GraphqlRails
23
24
  @description
24
25
  end
25
26
 
26
- def attribute(attribute_name, type: nil, description: nil, property: attribute_name)
27
+ def attribute(attribute_name, type: nil, **attribute_options)
27
28
  attributes[attribute_name.to_s] = \
28
29
  Attribute.new(
29
30
  attribute_name,
30
31
  type,
31
- description: description,
32
- property: property
32
+ attribute_options
33
33
  )
34
34
  end
35
35
 
36
36
  def graphql_type
37
- @graphql_type ||= begin
38
- type_name = name || name_by_class_name
39
- GrapqhlTypeBuilder.new(name: type_name, description: description, attributes: attributes).call
40
- end
37
+ @graphql_type ||= GrapqhlTypeBuilder.new(
38
+ name: name, description: description, attributes: attributes
39
+ ).call
41
40
  end
42
41
 
43
42
  private
@@ -10,7 +10,7 @@ require 'graphql_rails/router/resource_routes_builder'
10
10
  module GraphqlRails
11
11
  # graphql router that mimics Rails.application.routes
12
12
  class Router
13
- RAW_ACTION_NAMES = %i[rescue_from query_analyzer instrument].freeze
13
+ RAW_ACTION_NAMES = %i[rescue_from query_analyzer instrument default_max_page_size].freeze
14
14
 
15
15
  def self.draw(&block)
16
16
  router = new
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GraphqlRails
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
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.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Povilas Jurčys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-29 00:00:00.000000000 Z
11
+ date: 2018-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql