/// Resolves the value of a field that corresponds to a named type.
Resolves the value of a field that corresponds to a named type.
Resolves the value of a field that corresponds to a named type .
fn resolve_field_value_for_named_type<'a, R>(
    ctx: &ExecutionContext<'a, R>,
    object_type: &s::ObjectType,
    object_value: &Option<q::Value>,
    field: &q::Field,
    field_definition: &s::Field,
    type_name: &s::Name,
    argument_values: &HashMap<&q::Name, q::Value>,
) -> Result<q::Value, Vec<QueryExecutionError>>
where
    R: Resolver,
{
    // Try to resolve the type name into the actual type
    let named_type = sast::get_named_type(&ctx.schema.document, type_name)
        .ok_or_else(|| QueryExecutionError::NamedTypeError(type_name.to_string()))?;
    match named_type {
        // Let the resolver decide how the field (with the given object type)
        // is resolved into an entity based on the (potential) parent object
        s::TypeDefinition::Object(t) => ctx.resolver.resolve_object(
            object_value,
            field,
            field_definition,
            t.into(),
            argument_values,
            ctx.schema.types_for_interface(),
        ),
        // Let the resolver decide how values in the resolved object value
        // map to values of GraphQL enums
        s::TypeDefinition::Enum(t) => match object_value {
            Some(q::Value::Object(o)) => {
                ctx.resolver
                    .resolve_enum_value(field, t, o.get(&field.name))
            }
            _ => Ok(q::Value::Null),
        },
        // Let the resolver decide how values in the resolved object value
        // map to values of GraphQL scalars
        s::TypeDefinition::Scalar(t) => match object_value {
            Some(q::Value::Object(o)) => {
                ctx.resolver
                    .resolve_scalar_value(object_type, o, field, t, o.get(&field.name))
            }
            _ => Ok(q::Value::Null),
        },
        s::TypeDefinition::Interface(i) => ctx.resolver.resolve_object(
            object_value,
            field,
            field_definition,
            i.into(),
            argument_values,
            ctx.schema.types_for_interface(),
        ),
        s::TypeDefinition::Union(_) => Err(QueryExecutionError::Unimplemented("unions".to_owned())),
        s::TypeDefinition::InputObject(_) => unreachable!("input objects are never resolved"),
    }
    .map_err(|e| vec![e])
}
fn resolve_field_value_for_named_type < ' a , R > ( ctx : & ExecutionContext < ' a , R > , object_type : & s :: ObjectType , object_value : & Option < q :: Value > , field : & q :: Field , field_definition : & s :: Field , type_name : & s :: Name , argument_values : & HashMap < & q :: Name , q :: Value > , ) -> Result < q :: Value , Vec < QueryExecutionError > > where R : Resolver , { // Try to resolve the type name into the actual type let named_type = sast :: get_named_type ( & ctx . schema . document , type_name ) . ok_or_else ( | | QueryExecutionError :: NamedTypeError ( type_name . to_string ( ) ) ) ? ; match named_type { // Let the resolver decide how the field (with the given object type) // is resolved into an entity based on the (potential) parent object s :: TypeDefinition :: Object ( t ) => ctx . resolver . resolve_object ( object_value , field , field_definition , t . into ( ) , argument_values , ctx . schema . types_for_interface ( ) , ) , // Let the resolver decide how values in the resolved object value // map to values of GraphQL enums s :: TypeDefinition :: Enum ( t ) => match object_value { Some ( q :: Value :: Object ( o ) ) => { ctx . resolver . resolve_enum_value ( field , t , o . get ( & field . name ) ) } _ => Ok ( q :: Value :: Null ) , } , // Let the resolver decide how values in the resolved object value // map to values of GraphQL scalars s :: TypeDefinition :: Scalar ( t ) => match object_value { Some ( q :: Value :: Object ( o ) ) => { ctx . resolver . resolve_scalar_value ( object_type , o , field , t , o . get ( & field . name ) ) } _ => Ok ( q :: Value :: Null ) , } , s :: TypeDefinition :: Interface ( i ) => ctx . resolver . resolve_object ( object_value , field , field_definition , i . into ( ) , argument_values , ctx . schema . types_for_interface ( ) , ) , s :: TypeDefinition :: Union ( _ ) => Err ( QueryExecutionError :: Unimplemented ( " " . to_owned ( ) ) ) , s :: TypeDefinition :: InputObject ( _ ) => unreachable ! ( " " ) , } . map_err ( | e | vec ! [ e ] ) }
Resolves the value of a field that corresponds to a named type.
Resolves the value of a field that corresponds to a named type .
ctx
&ExecutionContext<'a, R>
object_type
&s::ObjectType
object_value
&Option<q::Value>
field
&q::Field
field_definition
&s::Field
type_name
&s::Name
argument_values
&HashMap<&q::Name, q::Value>