/// Resolves the value of a field that corresponds to a list type.
Resolves the value of a field that corresponds to a list type.
Resolves the value of a field that corresponds to a list type .
fn resolve_field_value_for_list_type<'a, R>(
    ctx: &ExecutionContext<'a, R>,
    object_type: &s::ObjectType,
    object_value: &Option<q::Value>,
    field: &q::Field,
    field_definition: &s::Field,
    inner_type: &s::Type,
    argument_values: &HashMap<&q::Name, q::Value>,
) -> Result<q::Value, Vec<QueryExecutionError>>
where
    R: Resolver,
{
    match inner_type {
        s::Type::NonNullType(inner_type) => resolve_field_value_for_list_type(
            ctx,
            object_type,
            object_value,
            field,
            field_definition,
            inner_type,
            argument_values,
        ),
        s::Type::NamedType(ref type_name) => {
            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 list field (with the given item object type)
                // is resolved into a entities based on the (potential) parent object
                s::TypeDefinition::Object(t) => ctx
                    .resolver
                    .resolve_objects(
                        object_value,
                        field,
                        field_definition,
                        t.into(),
                        argument_values,
                        ctx.schema.types_for_interface(),
                        ctx.block,
                        ctx.max_first,
                    )
                    .map_err(|e| vec![e]),
                // 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_values(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_values(field, &t, o.get(&field.name))
                    }
                    _ => Ok(q::Value::Null),
                },
                s::TypeDefinition::Interface(t) => ctx
                    .resolver
                    .resolve_objects(
                        object_value,
                        field,
                        field_definition,
                        t.into(),
                        argument_values,
                        ctx.schema.types_for_interface(),
                        ctx.block,
                        ctx.max_first,
                    )
                    .map_err(|e| vec![e]),
                s::TypeDefinition::Union(_) => Err(vec![QueryExecutionError::Unimplemented(
                    "unions".to_owned(),
                )]),
                s::TypeDefinition::InputObject(_) => {
                    unreachable!("input objects are never resolved")
                }
            }
        }
        // We don't support nested lists yet
        s::Type::ListType(_) => Err(vec![QueryExecutionError::Unimplemented(
            "nested list types".to_owned(),
        )]),
    }
}
fn resolve_field_value_for_list_type < ' a , R > ( ctx : & ExecutionContext < ' a , R > , object_type : & s :: ObjectType , object_value : & Option < q :: Value > , field : & q :: Field , field_definition : & s :: Field , inner_type : & s :: Type , argument_values : & HashMap < & q :: Name , q :: Value > , ) -> Result < q :: Value , Vec < QueryExecutionError > > where R : Resolver , { match inner_type { s :: Type :: NonNullType ( inner_type ) => resolve_field_value_for_list_type ( ctx , object_type , object_value , field , field_definition , inner_type , argument_values , ) , s :: Type :: NamedType ( ref type_name ) => { 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 list field (with the given item object type) // is resolved into a entities based on the (potential) parent object s :: TypeDefinition :: Object ( t ) => ctx . resolver . resolve_objects ( object_value , field , field_definition , t . into ( ) , argument_values , ctx . schema . types_for_interface ( ) , ctx . block , ctx . max_first , ) . map_err ( | e | vec ! [ e ] ) , // 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_values ( 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_values ( field , & t , o . get ( & field . name ) ) } _ => Ok ( q :: Value :: Null ) , } , s :: TypeDefinition :: Interface ( t ) => ctx . resolver . resolve_objects ( object_value , field , field_definition , t . into ( ) , argument_values , ctx . schema . types_for_interface ( ) , ctx . block , ctx . max_first , ) . map_err ( | e | vec ! [ e ] ) , s :: TypeDefinition :: Union ( _ ) => Err ( vec ! [ QueryExecutionError Unimplemented ( " " to_owned ( ) ) ] ) , s :: TypeDefinition :: InputObject ( _ ) => { unreachable ! ( " " ) } } } // We don't support nested lists yet s :: Type :: ListType ( _ ) => Err ( vec ! [ QueryExecutionError Unimplemented ( " " to_owned ( ) ) ] ) , } }
Resolves the value of a field that corresponds to a list type.
Resolves the value of a field that corresponds to a list type .
ctx
&ExecutionContext<'a, R>
object_type
&s::ObjectType
object_value
&Option<q::Value>
field
&q::Field
field_definition
&s::Field
inner_type
&s::Type
argument_values
&HashMap<&q::Name, q::Value>