graphql_rails 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/graphql_rails/attribute/attribute_type_parser.rb +10 -2
- data/lib/graphql_rails/attribute.rb +11 -12
- data/lib/graphql_rails/controller/action_configuration.rb +1 -1
- data/lib/graphql_rails/model/configuration.rb +7 -8
- data/lib/graphql_rails/router.rb +1 -1
- data/lib/graphql_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8937aa0faf2ed71af96882a43adb9518a454591784d17a1cf22e6c7486a5e90
|
4
|
+
data.tar.gz: a4ade684332f5d86f9bfeaf782dfad0a3d9732ef80f731ec071dd0f782ab420e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3297c4a8ecf0613b6458b10aa9ac19537e4697e95b9d984864e9ff8b28f06d4e2777402340fded49db42d48729f1d3fea6de36037a62069c80da96b0c8a9aec4
|
7
|
+
data.tar.gz: 2704a4e4417461da176ef7d3feb8f716b79b6677c3f25a1fcebcb42745461a444289d0b1f267a025f67db81cb8347323b05797d739bdbfedfa0f4f6eb81a65ac
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
@@ -15,7 +15,8 @@ module GraphqlRails
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def name(type_name = nil)
|
18
|
-
@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,
|
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
|
-
|
32
|
-
property: property
|
32
|
+
attribute_options
|
33
33
|
)
|
34
34
|
end
|
35
35
|
|
36
36
|
def graphql_type
|
37
|
-
@graphql_type ||=
|
38
|
-
|
39
|
-
|
40
|
-
end
|
37
|
+
@graphql_type ||= GrapqhlTypeBuilder.new(
|
38
|
+
name: name, description: description, attributes: attributes
|
39
|
+
).call
|
41
40
|
end
|
42
41
|
|
43
42
|
private
|
data/lib/graphql_rails/router.rb
CHANGED
@@ -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
|
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.
|
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-
|
11
|
+
date: 2018-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|