Sha256: f9c8654575b79a0822e908028f0500c8aef6bf849d094131fe9ed31622afb6c5
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true module GraphQL module Execution # This is one key-value pair in a GraphQL response. # @api private class FieldResult # @return [Any, Lazy] the GraphQL-ready response value, or a {Lazy} instance attr_reader :value # @return [GraphQL::Field] The field which resolved this value attr_reader :field # @return [SelectionResult] The result object that this field belongs to attr_reader :owner def initialize(field:, value:, owner:) @field = field @owner = owner self.value = value end # Set a new value for this field in the response. # It may be updated after resolving a {Lazy}. # If it is {Execute::PROPAGATE_NULL}, tell the owner to propagate null. # If the value is a {SelectionResult}, make a link with it, and if it's already null, # propagate the null as needed. # @param new_value [Any] The GraphQL-ready value def value=(new_value) if new_value.is_a?(SelectionResult) if new_value.invalid_null? new_value = GraphQL::Execution::Execute::PROPAGATE_NULL else new_value.owner = self end end if new_value == GraphQL::Execution::Execute::PROPAGATE_NULL if field.type.kind.non_null? @owner.propagate_null else @value = nil end else @value = new_value end end def inspect "#<FieldResult #{value.inspect} (#{field.type})>" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
graphql-1.5.4 | lib/graphql/execution/field_result.rb |
graphql-1.5.3 | lib/graphql/execution/field_result.rb |