Class: GraphQL::TypeKinds::TypeKind
- Inherits:
-
Object
- Object
- GraphQL::TypeKinds::TypeKind
- Defined in:
- lib/graph_ql/type_kinds.rb,
lib/graph_ql/type_kinds.rb
Overview
These objects are singletons, eg ‘GraphQL::TypeKinds::UNION`, `GraphQL::TypeKinds::SCALAR`.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#composite? ⇒ Boolean
Is this TypeKind composed of many values?.
-
#fields? ⇒ Boolean
Does this TypeKind have queryable fields?.
-
#initialize(name, resolves: false, fields: false, wraps: false, input: false) ⇒ TypeKind
constructor
A new instance of TypeKind.
-
#input? ⇒ Boolean
Is this TypeKind a valid query input?.
-
#resolve(type, value) ⇒ Object
Get the implementing type for ‘value` from `type` (no-op for TypeKinds which don’t ‘resolves?`).
-
#resolves? ⇒ Boolean
Does this TypeKind have multiple possible implementors?.
- #to_s ⇒ Object
-
#unwrap(type) ⇒ Object
Get the modified type for ‘type` (no-op for TypeKinds which don’t ‘wraps?`).
-
#wraps? ⇒ Boolean
Does this TypeKind modify another type?.
Constructor Details
#initialize(name, resolves: false, fields: false, wraps: false, input: false) ⇒ TypeKind
Returns a new instance of TypeKind.
6 7 8 9 10 11 12 13 |
# File 'lib/graph_ql/type_kinds.rb', line 6 def initialize(name, resolves: false, fields: false, wraps: false, input: false) @name = name @resolves = resolves @fields = fields @wraps = wraps @input = input @composite = fields? || resolves? end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/graph_ql/type_kinds.rb', line 5 def name @name end |
Instance Method Details
#composite? ⇒ Boolean
Is this TypeKind composed of many values?
25 |
# File 'lib/graph_ql/type_kinds.rb', line 25 def composite?; @composite; end |
#fields? ⇒ Boolean
Does this TypeKind have queryable fields?
18 |
# File 'lib/graph_ql/type_kinds.rb', line 18 def fields?; @fields; end |
#input? ⇒ Boolean
Is this TypeKind a valid query input?
22 |
# File 'lib/graph_ql/type_kinds.rb', line 22 def input?; @input; end |
#resolve(type, value) ⇒ Object
Get the implementing type for ‘value` from `type` (no-op for TypeKinds which don’t ‘resolves?`)
28 29 30 31 32 33 34 |
# File 'lib/graph_ql/type_kinds.rb', line 28 def resolve(type, value) if resolves? type.resolve_type(value) else type end end |
#resolves? ⇒ Boolean
Does this TypeKind have multiple possible implementors?
16 |
# File 'lib/graph_ql/type_kinds.rb', line 16 def resolves?; @resolves; end |
#to_s ⇒ Object
23 |
# File 'lib/graph_ql/type_kinds.rb', line 23 def to_s; @name; end |
#unwrap(type) ⇒ Object
Get the modified type for ‘type` (no-op for TypeKinds which don’t ‘wraps?`)
37 38 39 40 41 42 43 44 |
# File 'lib/graph_ql/type_kinds.rb', line 37 def unwrap(type) if wraps? wrapped_type = type.of_type wrapped_type.kind.unwrap(wrapped_type) else type end end |
#wraps? ⇒ Boolean
Does this TypeKind modify another type?
20 |
# File 'lib/graph_ql/type_kinds.rb', line 20 def wraps?; @wraps; end |