dry-graphql 2.0.1 → 2.1.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/lib/dry/graphql.rb +7 -2
- data/lib/dry/graphql/schema_builder.rb +4 -5
- data/lib/dry/graphql/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: 226af16add8ce3765bae17b9dcaef61b91f71784e646c7f6cb8457ed176adf27
|
4
|
+
data.tar.gz: 1c4e7811f12b9c1d623566ff0328efcb18b4f7c77dff9c0c0ffcc96f884a7cf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0db281d7c9a7b15c3e1fd554901ba7d35de47e109f0643221173184716d2bc5755874c03818b9e9803dad3b2058aceba9d6c61fb62954d16923e3cf2de98418f
|
7
|
+
data.tar.gz: 9cb411b43afe2ddb7ac3ffb96ae844645f91fa9939f8e8f209e70157d115b1d488dcd1c6f78f2599a3e898a0c7cb01894832d81e18c89ef349122711864ce44b
|
data/lib/dry/graphql.rb
CHANGED
@@ -7,14 +7,19 @@ require 'dry/graphql/schema_builder'
|
|
7
7
|
module Dry
|
8
8
|
# Module containing GraphQL enhancements
|
9
9
|
module GraphQL
|
10
|
+
# Generates a graphql_name from a class name
|
11
|
+
def self.generate_graphql_name(name)
|
12
|
+
name.to_s.capitalize.gsub('DryGraphQLGeneratedTypeForUser', '').gsub('::', '__')
|
13
|
+
end
|
14
|
+
|
10
15
|
# Extends Dry::Struct functionality
|
11
16
|
module Struct
|
12
17
|
def graphql_type(options = {})
|
13
18
|
return @graphql_type if @graphql_type
|
14
19
|
|
15
|
-
graphql_name =
|
20
|
+
graphql_name = Dry::GraphQL.generate_graphql_name(name)
|
16
21
|
graphql_schema = SchemaBuilder.build_graphql_schema_class(name)
|
17
|
-
graphql_schema.graphql_name(
|
22
|
+
graphql_schema.graphql_name(graphql_name)
|
18
23
|
schema_hash = schema.each_with_object({}) do |type, memo|
|
19
24
|
memo[type.name] = type.type
|
20
25
|
end
|
@@ -44,9 +44,8 @@ module Dry
|
|
44
44
|
|
45
45
|
def self.build_graphql_schema_class(name)
|
46
46
|
Dry::Core::ClassBuilder.new(
|
47
|
-
name: name,
|
48
|
-
parent: ::Dry::GraphQL::BaseObject
|
49
|
-
namespace: Dry::GraphQL::GeneratedTypes
|
47
|
+
name: "DryGraphQLGeneratedTypeFor#{name}",
|
48
|
+
parent: ::Dry::GraphQL::BaseObject
|
50
49
|
).call
|
51
50
|
end
|
52
51
|
|
@@ -166,7 +165,7 @@ module Dry
|
|
166
165
|
def map_schema(type)
|
167
166
|
graphql_name = generate_name
|
168
167
|
graphql_schema = self.class.build_graphql_schema_class(graphql_name)
|
169
|
-
graphql_schema.graphql_name
|
168
|
+
graphql_schema.graphql_name(graphql_name)
|
170
169
|
type_to_map = if type.respond_to?(:schema) && type.method(:schema).arity.zero?
|
171
170
|
type.schema
|
172
171
|
elsif type.respond_to?(:attributes)
|
@@ -184,7 +183,7 @@ module Dry
|
|
184
183
|
loop do
|
185
184
|
break if cursor.nil?
|
186
185
|
|
187
|
-
sanitized_name = cursor.name
|
186
|
+
sanitized_name = Dry::GraphQL.generate_graphql_name(cursor.name)
|
188
187
|
name_tree.unshift(sanitized_name)
|
189
188
|
cursor = cursor.parent
|
190
189
|
end
|
data/lib/dry/graphql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Ker-Seymer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|