dry-graphql 2.0.1 → 2.2.2

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: 618c4f369cc683525eb9d74c8e81a7e8b1ac7fc6cb763a7448f81ff52e087f20
4
- data.tar.gz: abaea2ed78505c65f80c7ae49ab65c89ada626e08d02006f2d70c1e7c67beeb1
3
+ metadata.gz: 50b33624e7670ba0827d9a279a1bafd83843bc2bd30de4f5cad7f3c8e1479bca
4
+ data.tar.gz: 8cbe479cbb31730a82cd1ea2a87141b3833267c39f14bf1e98fbd0a622b90097
5
5
  SHA512:
6
- metadata.gz: 40a5a3990b840d749ef6109ae2d86cb431f24bcb4fe5e4282a0018048c845e9581ec48c9b0ab4f99fbe4becd112ef2985704de19fc45e59838035c3cab790e26
7
- data.tar.gz: 8942a11ea9aca2f3c00fddeb3051247a15546f21c6708a753abe9e20f8cabf14065bf8c0213f332577c47e27902674fb6701c053307ab42cd20377e9b5e77acd
6
+ metadata.gz: b6e83d9f2135ed50f15eebe41ed9fd19373221405ea6fdf8a9ecb8ace6d551657ce2942ef8246427e8b2227f53df628afe23867a1f6e07c01239dc1495ca8e0d
7
+ data.tar.gz: f43d96f254186e5e67c096908c740a17b5831c24f6cdc2904641259b2aa922e37f2b1bdbf507a9153c13a388e9cd2e39640cdef319eb62b36fe1cfbe961f850b
data/.rubocop_todo.yml CHANGED
@@ -1,39 +1,48 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-10-21 16:52:46 -0400 using RuboCop version 0.75.0.
3
+ # on 2021-06-10 20:11:40 UTC using RuboCop version 1.16.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 3
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
13
+ Exclude:
14
+ - 'dry-graphql.gemspec'
15
+
16
+ # Offense count: 2
17
+ # Configuration parameters: AllowedMethods.
18
+ # AllowedMethods: enums
19
+ Lint/ConstantDefinitionInBlock:
20
+ Exclude:
21
+ - 'spec/dry/graphql_spec.rb'
22
+
23
+ # Offense count: 2
24
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
10
25
  Metrics/AbcSize:
11
- Max: 44
26
+ Max: 45
12
27
 
13
28
  # Offense count: 1
14
- # Configuration parameters: CountComments.
29
+ # Configuration parameters: CountComments, CountAsOne.
15
30
  Metrics/ClassLength:
16
31
  Max: 151
17
32
 
18
- # Offense count: 2
33
+ # Offense count: 1
34
+ # Configuration parameters: IgnoredMethods.
19
35
  Metrics/CyclomaticComplexity:
20
- Max: 14
36
+ Max: 15
21
37
 
22
38
  # Offense count: 2
23
- # Configuration parameters: CountComments, ExcludedMethods.
39
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
24
40
  Metrics/MethodLength:
25
41
  Max: 12
26
42
 
27
43
  # Offense count: 1
28
- # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
44
+ # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms.
29
45
  # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
30
46
  Naming/FileName:
31
47
  Exclude:
32
48
  - 'lib/dry-graphql.rb'
33
-
34
- # Offense count: 17
35
- # Cop supports --auto-correct.
36
- # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
37
- # URISchemes: http, https
38
- Metrics/LineLength:
39
- Max: 105
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.2
data/dry-graphql.gemspec CHANGED
@@ -35,10 +35,10 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_runtime_dependency 'dry-struct', '~> 1.0'
37
37
  spec.add_runtime_dependency 'dry-types', '~> 1.1'
38
- spec.add_runtime_dependency 'graphql', '~> 1.9.0'
38
+ spec.add_runtime_dependency 'graphql', '~> 1.10'
39
39
 
40
40
  spec.add_development_dependency 'appraisal'
41
- spec.add_development_dependency 'bundler', '~> 1.16'
41
+ spec.add_development_dependency 'bundler', '~> 2.2.16'
42
42
  spec.add_development_dependency 'rake', '~> 10.0'
43
43
  spec.add_development_dependency 'rspec', '~> 3.0'
44
44
  end
@@ -17,6 +17,7 @@ module Dry
17
17
  attr_reader :field, :type, :options, :schema, :name, :parent
18
18
 
19
19
  class TypeMappingError < StandardError; end
20
+
20
21
  class NameGenerationError < StandardError; end
21
22
 
22
23
  def initialize(name: nil, type: nil, schema: nil, parent: nil, options: {})
@@ -28,7 +29,7 @@ module Dry
28
29
  end
29
30
 
30
31
  def with(opts)
31
- self.class.new({
32
+ self.class.new(**{
32
33
  name: @name, type: @type, schema: @schema, options: @options,
33
34
  parent: self
34
35
  }.merge(opts))
@@ -44,9 +45,8 @@ module Dry
44
45
 
45
46
  def self.build_graphql_schema_class(name)
46
47
  Dry::Core::ClassBuilder.new(
47
- name: name,
48
- parent: ::Dry::GraphQL::BaseObject,
49
- namespace: Dry::GraphQL::GeneratedTypes
48
+ name: "DryGraphQLGeneratedTypeFor#{name}",
49
+ parent: ::Dry::GraphQL::BaseObject
50
50
  ).call
51
51
  end
52
52
 
@@ -166,7 +166,7 @@ module Dry
166
166
  def map_schema(type)
167
167
  graphql_name = generate_name
168
168
  graphql_schema = self.class.build_graphql_schema_class(graphql_name)
169
- graphql_schema.graphql_name
169
+ graphql_schema.graphql_name(graphql_name)
170
170
  type_to_map = if type.respond_to?(:schema) && type.method(:schema).arity.zero?
171
171
  type.schema
172
172
  elsif type.respond_to?(:attributes)
@@ -184,7 +184,7 @@ module Dry
184
184
  loop do
185
185
  break if cursor.nil?
186
186
 
187
- sanitized_name = cursor.name.to_s.capitalize.gsub('::', '__')
187
+ sanitized_name = Dry::GraphQL.generate_graphql_name(cursor)
188
188
  name_tree.unshift(sanitized_name)
189
189
  cursor = cursor.parent
190
190
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module GraphQL
5
- VERSION = '2.0.1'
5
+ VERSION = '2.2.2'
6
6
  end
7
7
  end
data/lib/dry/graphql.rb CHANGED
@@ -7,20 +7,27 @@ 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(obj)
12
+ return obj.graphql_name if obj.respond_to?(:graphql_name)
13
+
14
+ obj.name.to_s.capitalize.gsub('DryGraphQLGeneratedTypeForUser', '').gsub('::', '__')
15
+ end
16
+
10
17
  # Extends Dry::Struct functionality
11
18
  module Struct
12
19
  def graphql_type(options = {})
13
20
  return @graphql_type if @graphql_type
14
21
 
15
- graphql_name = name.to_s.gsub('::', '__')
22
+ graphql_name = Dry::GraphQL.generate_graphql_name(self)
16
23
  graphql_schema = SchemaBuilder.build_graphql_schema_class(name)
17
- graphql_schema.graphql_name(name)
24
+ graphql_schema.graphql_name(graphql_name)
18
25
  schema_hash = schema.each_with_object({}) do |type, memo|
19
26
  memo[type.name] = type.type
20
27
  end
21
28
 
22
29
  opts = { name: graphql_name, type: schema_hash, schema: graphql_schema, options: options }
23
- @graphql_type ||= SchemaBuilder.new(opts).graphql_type
30
+ @graphql_type ||= SchemaBuilder.new(**opts).graphql_type
24
31
  end
25
32
  end
26
33
 
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.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Ker-Seymer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-22 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.9.0
47
+ version: '1.10'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.9.0
54
+ version: '1.10'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: appraisal
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.16'
75
+ version: 2.2.16
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.16'
82
+ version: 2.2.16
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -119,6 +119,7 @@ files:
119
119
  - ".rspec"
120
120
  - ".rubocop.yml"
121
121
  - ".rubocop_todo.yml"
122
+ - ".tool-versions"
122
123
  - ".travis.yml"
123
124
  - Appraisals
124
125
  - CODE_OF_CONDUCT.md
@@ -151,7 +152,7 @@ homepage: https://github.com/adhawk/dry-graphql
151
152
  licenses:
152
153
  - MIT
153
154
  metadata: {}
154
- post_install_message:
155
+ post_install_message:
155
156
  rdoc_options: []
156
157
  require_paths:
157
158
  - lib
@@ -166,9 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  - !ruby/object:Gem::Version
167
168
  version: '0'
168
169
  requirements: []
169
- rubyforge_project:
170
- rubygems_version: 2.7.8
171
- signing_key:
170
+ rubygems_version: 3.1.4
171
+ signing_key:
172
172
  specification_version: 4
173
173
  summary: Integrate dry-types/dry-struct with graphql-ruby
174
174
  test_files: []