Class: GraphQL::Stitching::TypeResolver
- Inherits:
-
Object
- Object
- GraphQL::Stitching::TypeResolver
- Extended by:
- ArgumentsParser, KeysParser
- Defined in:
- lib/graphql/stitching/type_resolver.rb,
lib/graphql/stitching/type_resolver/keys.rb,
lib/graphql/stitching/type_resolver/arguments.rb
Overview
Defines a type resolver query that provides direct access to an entity type.
Defined Under Namespace
Modules: ArgumentsParser, KeysParser Classes: Argument, ArgumentValue, EnumArgumentValue, FieldNode, Key, KeyArgumentValue, KeyField, KeyFieldSet, LiteralArgumentValue, ObjectArgumentValue
Constant Summary collapse
- EXPORT_PREFIX =
"_export_"
- EMPTY_FIELD_SET =
KeyFieldSet.new(GraphQL::Stitching::EMPTY_ARRAY)
- TYPENAME_EXPORT_NODE =
FieldNode.build( field_alias: "#{EXPORT_PREFIX}#{TYPENAME}", field_name: TYPENAME, )
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
parsed resolver Argument structures.
-
#field ⇒ Object
readonly
name of the root field to query.
-
#key ⇒ Object
readonly
a key field to select from prior locations, sent as resolver argument.
-
#location ⇒ Object
readonly
location name providing the resolver query.
-
#type_name ⇒ Object
readonly
name of merged type fulfilled through this resolver.
Class Method Summary collapse
-
.use_static_version? ⇒ Boolean
only intended for testing...
Instance Method Summary collapse
- #==(other) ⇒ Object
- #as_json ⇒ Object
-
#initialize(location:, type_name: nil, list: false, field: nil, key: nil, arguments: nil) ⇒ TypeResolver
constructor
A new instance of TypeResolver.
- #inspect ⇒ Object
-
#list? ⇒ Boolean
specifies when the resolver is a list query.
- #version ⇒ Object
Methods included from ArgumentsParser
parse_arguments_with_field, parse_arguments_with_type_defs
Methods included from KeysParser
export_key, export_key?, parse_key, parse_key_with_types
Constructor Details
#initialize(location:, type_name: nil, list: false, field: nil, key: nil, arguments: nil) ⇒ TypeResolver
Returns a new instance of TypeResolver.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/graphql/stitching/type_resolver.rb', line 35 def initialize( location:, type_name: nil, list: false, field: nil, key: nil, arguments: nil ) @location = location @type_name = type_name @list = list @field = field @key = key @arguments = arguments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
parsed resolver Argument structures.
33 34 35 |
# File 'lib/graphql/stitching/type_resolver.rb', line 33 def arguments @arguments end |
#field ⇒ Object (readonly)
name of the root field to query.
27 28 29 |
# File 'lib/graphql/stitching/type_resolver.rb', line 27 def field @field end |
#key ⇒ Object (readonly)
a key field to select from prior locations, sent as resolver argument.
30 31 32 |
# File 'lib/graphql/stitching/type_resolver.rb', line 30 def key @key end |
#location ⇒ Object (readonly)
location name providing the resolver query.
21 22 23 |
# File 'lib/graphql/stitching/type_resolver.rb', line 21 def location @location end |
#type_name ⇒ Object (readonly)
name of merged type fulfilled through this resolver.
24 25 26 |
# File 'lib/graphql/stitching/type_resolver.rb', line 24 def type_name @type_name end |
Class Method Details
.use_static_version? ⇒ Boolean
only intended for testing...
15 16 17 |
# File 'lib/graphql/stitching/type_resolver.rb', line 15 def use_static_version? @use_static_version ||= false end |
Instance Method Details
#==(other) ⇒ Object
64 65 66 |
# File 'lib/graphql/stitching/type_resolver.rb', line 64 def ==(other) self.class == other.class && self.as_json == other.as_json end |
#as_json ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/graphql/stitching/type_resolver.rb', line 68 def as_json { location: location, type_name: type_name, list: list?, field: field, key: key.to_definition, arguments: arguments.map(&:to_definition).join(", "), argument_types: arguments.map(&:to_type_definition).join(", "), }.tap(&:compact!) end |
#inspect ⇒ Object
80 81 82 |
# File 'lib/graphql/stitching/type_resolver.rb', line 80 def inspect as_json.to_json end |
#list? ⇒ Boolean
specifies when the resolver is a list query.
52 53 54 |
# File 'lib/graphql/stitching/type_resolver.rb', line 52 def list? @list end |