Module: HQ::GraphQL::Types
- Defined in:
- lib/hq/graphql/types.rb,
lib/hq/graphql/types/uuid.rb,
lib/hq/graphql/types/object.rb
Defined Under Namespace
Classes: Error, Object, UUID
Class Method Summary
collapse
Class Method Details
.[](key, is_nil = false) ⇒ Object
28
29
30
|
# File 'lib/hq/graphql/types.rb', line 28
def self.[](key, is_nil = false)
registry[[key, is_nil]]
end
|
.[]=(key, is_nil = false, value) ⇒ Object
24
25
26
|
# File 'lib/hq/graphql/types.rb', line 24
def self.[]=(key, is_nil = false, value)
registry[[key, is_nil]] = value
end
|
.register(k, v) ⇒ Object
20
21
22
|
# File 'lib/hq/graphql/types.rb', line 20
def self.register(k, v)
self[k] = v
end
|
13
14
15
16
17
18
|
# File 'lib/hq/graphql/types.rb', line 13
def self.registry
@registry ||= Hash.new do |hash, options|
klass, nil_klass = Array(options)
hash[klass] = nil_klass ? nil_query_klass(klass) : klass_for(klass)
end
end
|
Only being used in testing
57
58
59
|
# File 'lib/hq/graphql/types.rb', line 57
def self.reset!
@registry = nil
end
|
.type_from_column(column) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/hq/graphql/types.rb', line 32
def self.type_from_column(column)
graphql_type =
case column.type
when :uuid
::HQ::GraphQL::Types::UUID
when :json, :jsonb
::HQ::GraphQL::Types::Object
when :integer
::GraphQL::Types::Int
when :decimal
::GraphQL::Types::Float
when :boolean
::GraphQL::Types::Boolean
when :date
::GraphQL::Types::ISO8601Date
when :datetime
::GraphQL::Types::ISO8601DateTime
else
::GraphQL::Types::String
end
column.array ? [graphql_type] : graphql_type
end
|