validate method

List<GraphQLError>? validate(
  1. TypeConditionNode? typeCondition,
  2. String? name
)

Execute the validation

Implementation

List<GraphQLError>? validate(TypeConditionNode? typeCondition, String? name) {
  if (typeCondition != null) {
    final type = convertTypeOrNull(typeCondition.on, schema.typeMap);
    if (type != null &&
        type is! GraphQLUnionType &&
        type is! GraphQLObjectType) {
      return [
        GraphQLError(
          'Fragment${name == null ? '' : ' "$name"'} cannot condition'
          ' on non composite type "$type".',
          locations: GraphQLErrorLocation.listFromSource(
            typeCondition.span?.start ?? typeCondition.on.name.span?.start,
          ),
          extensions: _fragmentsOnCompositeTypesSpec.extensions(),
        )
      ];
    }
  }
}