fn does_fragment_type_apply(
    ctx: ExecutionContext<'_, impl Resolver>,
    object_type: &s::ObjectType,
    fragment_type: &q::TypeCondition,
) -> bool {
    // This is safe to do, as TypeCondition only has a single `On` variant.
    let q::TypeCondition::On(ref name) = fragment_type;

    // Resolve the type the fragment applies to based on its name
    let named_type = sast::get_named_type(&ctx.schema.document, name);

    match named_type {
        // The fragment applies to the object type if its type is the same object type
        Some(s::TypeDefinition::Object(ot)) => object_type == ot,

        // The fragment also applies to the object type if its type is an interface
        // that the object type implements
        Some(s::TypeDefinition::Interface(it)) => {
            object_type.implements_interfaces.contains(&it.name)
        }

        // The fragment also applies to an object type if its type is a union that
        // the object type is one of the possible types for
        Some(s::TypeDefinition::Union(ut)) => ut.types.contains(&object_type.name),

        // In all other cases, the fragment does not apply
        _ => false,
    }
}
/// Determines whether a fragment is applicable to the given object type.
Determines whether a fragment is applicable to the given object type.
Determines whether a fragment is applicable to the given object type .
fn does_fragment_type_apply(
    ctx: ExecutionContext<'_, impl Resolver>,
    object_type: &s::ObjectType,
    fragment_type: &q::TypeCondition,
) -> bool {
    // This is safe to do, as TypeCondition only has a single `On` variant.
    let q::TypeCondition::On(ref name) = fragment_type;
    // Resolve the type the fragment applies to based on its name
    let named_type = sast::get_named_type(&ctx.schema.document, name);
    match named_type {
        // The fragment applies to the object type if its type is the same object type
        Some(s::TypeDefinition::Object(ot)) => object_type == ot,
        // The fragment also applies to the object type if its type is an interface
        // that the object type implements
        Some(s::TypeDefinition::Interface(it)) => {
            object_type.implements_interfaces.contains(&it.name)
        }
        // The fragment also applies to an object type if its type is a union that
        // the object type is one of the possible types for
        Some(s::TypeDefinition::Union(ut)) => ut.types.contains(&object_type.name),
        // In all other cases, the fragment does not apply
        _ => false,
    }
}
fn does_fragment_type_apply ( ctx : ExecutionContext < ' _ , impl Resolver > , object_type : & s :: ObjectType , fragment_type : & q :: TypeCondition , ) -> bool { // This is safe to do, as TypeCondition only has a single `On` variant. let q :: TypeCondition :: On ( ref name ) = fragment_type ; // Resolve the type the fragment applies to based on its name let named_type = sast :: get_named_type ( & ctx . schema . document , name ) ; match named_type { // The fragment applies to the object type if its type is the same object type Some ( s :: TypeDefinition :: Object ( ot ) ) => object_type == ot , // The fragment also applies to the object type if its type is an interface // that the object type implements Some ( s :: TypeDefinition :: Interface ( it ) ) => { object_type . implements_interfaces . contains ( & it . name ) } // The fragment also applies to an object type if its type is a union that // the object type is one of the possible types for Some ( s :: TypeDefinition :: Union ( ut ) ) => ut . types . contains ( & object_type . name ) , // In all other cases, the fragment does not apply _ => false , } }
Determines whether a fragment is applicable to the given object type.
Determines whether a fragment is applicable to the given object type .
ctx
ExecutionContext<'_, impl Resolver>
object_type
&s::ObjectType
fragment_type
&q::TypeCondition
ctx
ExecutionContext<'_, impl Resolver>
object_type
&s::ObjectType
fragment_type
&q::TypeCondition