isSubType static method

bool isSubType(
  1. AbstractType abstractType,
  2. ObjectTypeDefinition objectType
)

Determine whether objectType is a acceptable as the given abstractType

Implementation

static bool isSubType(
  AbstractType abstractType,
  ObjectTypeDefinition objectType,
) {
  if (abstractType is UnionTypeDefinition) {
    return abstractType.typeNames.contains(objectType.name);
  }
  if (abstractType is InterfaceTypeDefinition) {
    return objectType.interfaceNames
        .map((n) => n.name)
        .contains(abstractType.name);
  }

  throw ArgumentError("$abstractType is unsupported");
}