dry-graphql 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 618c4f369cc683525eb9d74c8e81a7e8b1ac7fc6cb763a7448f81ff52e087f20
4
- data.tar.gz: abaea2ed78505c65f80c7ae49ab65c89ada626e08d02006f2d70c1e7c67beeb1
3
+ metadata.gz: 226af16add8ce3765bae17b9dcaef61b91f71784e646c7f6cb8457ed176adf27
4
+ data.tar.gz: 1c4e7811f12b9c1d623566ff0328efcb18b4f7c77dff9c0c0ffcc96f884a7cf4
5
5
  SHA512:
6
- metadata.gz: 40a5a3990b840d749ef6109ae2d86cb431f24bcb4fe5e4282a0018048c845e9581ec48c9b0ab4f99fbe4becd112ef2985704de19fc45e59838035c3cab790e26
7
- data.tar.gz: 8942a11ea9aca2f3c00fddeb3051247a15546f21c6708a753abe9e20f8cabf14065bf8c0213f332577c47e27902674fb6701c053307ab42cd20377e9b5e77acd
6
+ metadata.gz: 0db281d7c9a7b15c3e1fd554901ba7d35de47e109f0643221173184716d2bc5755874c03818b9e9803dad3b2058aceba9d6c61fb62954d16923e3cf2de98418f
7
+ data.tar.gz: 9cb411b43afe2ddb7ac3ffb96ae844645f91fa9939f8e8f209e70157d115b1d488dcd1c6f78f2599a3e898a0c7cb01894832d81e18c89ef349122711864ce44b
@@ -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 = name.to_s.gsub('::', '__')
20
+ graphql_name = Dry::GraphQL.generate_graphql_name(name)
16
21
  graphql_schema = SchemaBuilder.build_graphql_schema_class(name)
17
- graphql_schema.graphql_name(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.to_s.capitalize.gsub('::', '__')
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module GraphQL
5
- VERSION = '2.0.1'
5
+ VERSION = '2.1.0'
6
6
  end
7
7
  end
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.1
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-10-22 00:00:00.000000000 Z
11
+ date: 2019-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct