Class: GraphQL::Stitching::TypeResolver::KeyArgumentValue Private
- Inherits:
-
ArgumentValue
- Object
- ArgumentValue
- GraphQL::Stitching::TypeResolver::KeyArgumentValue
- Defined in:
- lib/graphql/stitching/type_resolver/arguments.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A key input value
Instance Attribute Summary
Attributes inherited from ArgumentValue
Instance Method Summary collapse
- #build(origin_obj) ⇒ Object private
-
#initialize(value) ⇒ KeyArgumentValue
constructor
private
A new instance of KeyArgumentValue.
- #key? ⇒ Boolean private
- #print ⇒ Object private
- #verify_key(arg, key) ⇒ Object private
Methods inherited from ArgumentValue
Constructor Details
#initialize(value) ⇒ KeyArgumentValue
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of KeyArgumentValue.
123 124 125 |
# File 'lib/graphql/stitching/type_resolver/arguments.rb', line 123 def initialize(value) super(Array(value)) end |
Instance Method Details
#build(origin_obj) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
147 148 149 150 151 |
# File 'lib/graphql/stitching/type_resolver/arguments.rb', line 147 def build(origin_obj) value.each_with_index.reduce(origin_obj) do |obj, (ns, idx)| obj[idx.zero? ? TypeResolver.export_key(ns) : ns] end end |
#key? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
127 128 129 |
# File 'lib/graphql/stitching/type_resolver/arguments.rb', line 127 def key? true end |
#print ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
153 154 155 |
# File 'lib/graphql/stitching/type_resolver/arguments.rb', line 153 def print "$.#{value.join(".")}" end |
#verify_key(arg, key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/graphql/stitching/type_resolver/arguments.rb', line 131 def verify_key(arg, key) key_field = value.reduce(TypeResolver::KeyField.new("", inner: key)) do |field, ns| if ns == TYPENAME TypeResolver::KeyField.new(TYPENAME) elsif field field.inner.find { _1.name == ns } end end # still not capturing enough type information to accurately compare key/arg types... # best we can do for now is to verify the argument insertion matches a key path. if key_field.nil? raise CompositionError, "Argument `#{arg.name}: #{print}` cannot insert key `#{key.to_definition}`." end end |