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
- #fields? ⇒ Boolean
-
#initialize(name, resolves: false, fields: false, wraps: false) ⇒ TypeKind
constructor
A new instance of TypeKind.
- #resolve(type, value) ⇒ Object
- #resolves? ⇒ Boolean
- #to_s ⇒ Object
- #unwrap(type) ⇒ Object
- #wraps? ⇒ Boolean
Constructor Details
#initialize(name, resolves: false, fields: false, wraps: false) ⇒ TypeKind
Returns a new instance of TypeKind.
4 5 6 7 8 9 |
# File 'lib/graph_ql/type_kinds.rb', line 4 def initialize(name, resolves: false, fields: false, wraps: false) @name = name @resolves = resolves @fields = fields @wraps = wraps 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
#fields? ⇒ Boolean
12 |
# File 'lib/graph_ql/type_kinds.rb', line 12 def fields?; @fields; end |
#resolve(type, value) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/graph_ql/type_kinds.rb', line 16 def resolve(type, value) if resolves? type.resolve_type(value) else type end end |
#resolves? ⇒ Boolean
11 |
# File 'lib/graph_ql/type_kinds.rb', line 11 def resolves?; @resolves; end |
#to_s ⇒ Object
14 |
# File 'lib/graph_ql/type_kinds.rb', line 14 def to_s; @name; end |
#unwrap(type) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/graph_ql/type_kinds.rb', line 24 def unwrap(type) if wraps? wrapped_type = type.of_type wrapped_type.kind.unwrap(wrapped_type) else type end end |
#wraps? ⇒ Boolean
13 |
# File 'lib/graph_ql/type_kinds.rb', line 13 def wraps?; @wraps; end |