Class: GraphQL::TypeKinds::TypeKind
- Inherits:
-
Object
- Object
- GraphQL::TypeKinds::TypeKind
- Defined in:
- lib/graph_ql/type_kinds.rb,
lib/graph_ql/type_kinds.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #composite? ⇒ Boolean
- #fields? ⇒ Boolean
-
#initialize(name, resolves: false, fields: false, wraps: false, input: false) ⇒ TypeKind
constructor
A new instance of TypeKind.
- #input? ⇒ Boolean
- #resolve(type, value) ⇒ Object
- #resolves? ⇒ Boolean
- #to_s ⇒ Object
- #unwrap(type) ⇒ Object
- #wraps? ⇒ Boolean
Constructor Details
#initialize(name, resolves: false, fields: false, wraps: false, input: false) ⇒ TypeKind
Returns a new instance of TypeKind.
4 5 6 7 8 9 10 11 |
# File 'lib/graph_ql/type_kinds.rb', line 4 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.
3 4 5 |
# File 'lib/graph_ql/type_kinds.rb', line 3 def name @name end |
Instance Method Details
#composite? ⇒ Boolean
18 |
# File 'lib/graph_ql/type_kinds.rb', line 18 def composite?; @composite; end |
#fields? ⇒ Boolean
14 |
# File 'lib/graph_ql/type_kinds.rb', line 14 def fields?; @fields; end |
#input? ⇒ Boolean
16 |
# File 'lib/graph_ql/type_kinds.rb', line 16 def input?; @input; end |
#resolve(type, value) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/graph_ql/type_kinds.rb', line 20 def resolve(type, value) if resolves? type.resolve_type(value) else type end end |
#resolves? ⇒ Boolean
13 |
# File 'lib/graph_ql/type_kinds.rb', line 13 def resolves?; @resolves; end |
#to_s ⇒ Object
17 |
# File 'lib/graph_ql/type_kinds.rb', line 17 def to_s; @name; end |
#unwrap(type) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/graph_ql/type_kinds.rb', line 28 def unwrap(type) if wraps? wrapped_type = type.of_type wrapped_type.kind.unwrap(wrapped_type) else type end end |
#wraps? ⇒ Boolean
15 |
# File 'lib/graph_ql/type_kinds.rb', line 15 def wraps?; @wraps; end |