hq-graphql 2.0.1 → 2.0.2

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: e2508bf165d504937a9ea21ecc4b463e98e75c4e0d1ae12156df59ed649e4c2d
4
- data.tar.gz: 07c40cac0b734c307953864ba415700b0a5dad4769d48e168361449cbe3e3a8e
3
+ metadata.gz: d9b7415b2d65e1530b8e56c4981759200f341bf15aa5fb6e6ceebc08c806821f
4
+ data.tar.gz: 4708e50afcb152a7a7cb2b32f6c26d74a69412bea0d1575c96cdde396d596ac8
5
5
  SHA512:
6
- metadata.gz: 8c7d4b1e507b25c0288a55387c183079e2dfbe8fec512a15c09d47f1352ed14655dd2507f86f996848a7bf4513969d59fa16f6df8b873ce74488867b31a9832e
7
- data.tar.gz: 86c8781c2e074dc2d6882144d8604f33d11cd943f1e3effe0949c5efb8ee26ee9b687c697e2e30e146a7651b41f31252b7ff7bfeb237ff331a917a8aba02e798
6
+ metadata.gz: 01beff2971f13a64651d3170bde7a0b11396a9fb797bc4dfb8d95560af14bfec55144dd03de0a712344e4cd1aed0c3206964ac09e12a08beab452293d1710e6c
7
+ data.tar.gz: 4bea766a1789a5228777ea218aabeed5e50c06585d0259989bb97677ff3d0c0cf28b65497d21c35caf3a8e07d742c0c50888917762d563d53999dc1eb2a8d897
@@ -5,7 +5,7 @@
5
5
  module HQ
6
6
  module GraphQL
7
7
  class Config < T::Struct
8
- DefaultScopeProc = T.type_alias(T.proc.params(arg0: T.untyped, arg1: ::GraphQL::Query::Context).returns(T.untyped))
8
+ DefaultScopeProc = T.type_alias { T.proc.params(arg0: T.untyped, arg1: ::GraphQL::Query::Context).returns(T.untyped) }
9
9
  prop :default_scope, DefaultScopeProc, default: ->(scope, _context) { scope }
10
10
  end
11
11
  end
@@ -5,13 +5,13 @@ module HQ
5
5
  module GraphQL
6
6
  module Resource
7
7
  module Mutation
8
- def self.build(model_name, graphql_name:, require_primary_key: false, show_copy: false, &block)
8
+ def self.build(model_name, graphql_name:, require_primary_key: false, nil_klass: false, &block)
9
9
  Class.new(::HQ::GraphQL::Mutation) do
10
10
  graphql_name graphql_name
11
11
 
12
12
  lazy_load do
13
13
  field :errors, ::HQ::GraphQL::Types::Object, null: false
14
- field :resource, ::HQ::GraphQL::Types[model_name, show_copy], null: true
14
+ field :resource, ::HQ::GraphQL::Types[model_name, nil_klass], null: true
15
15
  end
16
16
 
17
17
  instance_eval(&block)
@@ -20,9 +20,7 @@ module HQ
20
20
  lazy_load do
21
21
  klass = model_name.constantize
22
22
  primary_key = klass.primary_key
23
- pk_column = klass.columns.detect { |c| c.name == primary_key.to_s }
24
-
25
- argument primary_key, ::HQ::GraphQL::Types.type_from_column(pk_column), required: true
23
+ argument primary_key, ::GraphQL::Types::ID, required: true
26
24
  end
27
25
  end
28
26
 
@@ -12,6 +12,7 @@ module HQ
12
12
  super
13
13
  ::HQ::GraphQL.types << base
14
14
  base.include Scalars
15
+ base.include ::GraphQL::Types
15
16
  end
16
17
 
17
18
  module ClassMethods
@@ -53,8 +54,8 @@ module HQ
53
54
  @input_klass ||= build_input_object
54
55
  end
55
56
 
56
- def input_result_klass
57
- @input_result_klass ||= build_graphql_object(name: "#{graphql_name}Copy", auto_nil: false)
57
+ def nil_query_klass
58
+ @nil_query_klass ||= build_graphql_object(name: "#{graphql_name}Copy", auto_nil: false)
58
59
  end
59
60
 
60
61
  def query_klass
@@ -71,10 +72,6 @@ module HQ
71
72
  @input_klass = build_input_object(**options, &block)
72
73
  end
73
74
 
74
- def input_result(**options, &block)
75
- @input_result_klass = build_graphql_object(name: "#{graphql_name}Copy", **options, auto_nil: false, &block)
76
- end
77
-
78
75
  def mutations(create: true, copy: true, update: true, destroy: true)
79
76
  scoped_graphql_name = graphql_name
80
77
  scoped_model_name = model_name
@@ -111,7 +108,7 @@ module HQ
111
108
  model_name,
112
109
  graphql_name: "#{scoped_graphql_name}Copy",
113
110
  require_primary_key: true,
114
- show_copy: true
111
+ nil_klass: true
115
112
  ) do
116
113
  define_method(:resolve) do |**args|
117
114
  resource = scoped_self.find_record(args, context)
@@ -239,9 +236,8 @@ module HQ
239
236
  def_root field_name, is_array: false, null: true do
240
237
  klass = scoped_self.model_klass
241
238
  primary_key = klass.primary_key
242
- pk_column = klass.columns.detect { |c| c.name == primary_key.to_s }
243
239
 
244
- argument primary_key, ::HQ::GraphQL::Types.type_from_column(pk_column), required: true
240
+ argument primary_key, ::GraphQL::Types::ID, required: true
245
241
 
246
242
  define_method(:resolve) do |**attrs|
247
243
  scoped_self.find_record(attrs, context)
@@ -10,8 +10,8 @@ module HQ
10
10
 
11
11
  def self.[](key, *args)
12
12
  @types ||= Hash.new do |hash, options|
13
- klass, show_copy = Array(options)
14
- hash[klass] = show_copy ? copy_klass(klass) : klass_for(klass)
13
+ klass, nil_klass = Array(options)
14
+ hash[klass] = nil_klass ? nil_query_klass(klass) : klass_for(klass)
15
15
  end
16
16
  @types[[key, *args]]
17
17
  end
@@ -44,8 +44,8 @@ module HQ
44
44
  class << self
45
45
  private
46
46
 
47
- def copy_klass(klass_or_string)
48
- find_klass(klass_or_string, :input_result_klass)
47
+ def nil_query_klass(klass_or_string)
48
+ find_klass(klass_or_string, :nil_query_klass)
49
49
  end
50
50
 
51
51
  def klass_for(klass_or_string)
@@ -3,6 +3,6 @@
3
3
 
4
4
  module HQ
5
5
  module GraphQL
6
- VERSION = "2.0.1"
6
+ VERSION = "2.0.2"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hq-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Jones
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-24 00:00:00.000000000 Z
11
+ date: 2019-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -86,6 +86,20 @@ dependencies:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: sprockets
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "<"
94
+ - !ruby/object:Gem::Version
95
+ version: 4.0.0
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "<"
101
+ - !ruby/object:Gem::Version
102
+ version: 4.0.0
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: byebug
91
105
  requirement: !ruby/object:Gem::Requirement