doesFragmentTypeApply function

bool doesFragmentTypeApply(
  1. GraphQLObjectType objectType,
  2. TypeConditionNode fragmentType,
  3. GraphQLSchema schema
)

Implementation

bool doesFragmentTypeApply(
  GraphQLObjectType objectType,
  TypeConditionNode fragmentType,
  GraphQLSchema schema,
) {
  final type = convertType(fragmentType.on, schema.typeMap);

  return type.whenMaybe(
    object: (type) {
      if (type.isInterface) {
        return objectType.isImplementationOf(type);
      } else {
        return type.name == objectType.name;
      }
    },
    union: (type) {
      return type.possibleTypes.any((t) => objectType.isImplementationOf(t));
    },
    orElse: (_) => false,
  );
}