when<O> method
O
when<O>({
- required O enum_(
- GraphQLEnumType<
Json>
- GraphQLEnumType<
- required O scalar(),
- required O object(
- GraphQLObjectType<
Json>
- GraphQLObjectType<
- required O input(
- GraphQLInputObjectType<
Json>
- GraphQLInputObjectType<
- required O union(
- GraphQLUnionType<
Json>
- GraphQLUnionType<
- required O list(
- GraphQLListType
- required O nonNullable(),
inherited
Executes any of the provided function with this
as argument.
The function executed depends on the type of this
Implementation
O when<O>({
required O Function(GraphQLEnumType<Value>) enum_,
required O Function(GraphQLScalarType<Value, Serialized>) scalar,
required O Function(GraphQLObjectType<Value>) object,
required O Function(GraphQLInputObjectType<Value>) input,
required O Function(GraphQLUnionType<Value>) union,
required O Function(GraphQLListType) list,
required O Function(GraphQLNonNullType<Value, Serialized>) nonNullable,
}) {
final GraphQLType type = this;
if (type is GraphQLEnumType<Value>) {
return enum_(type);
} else if (type is GraphQLScalarType<Value, Serialized>) {
return scalar(type);
} else if (type is GraphQLObjectType<Value>) {
return object(type);
} else if (type is GraphQLInputObjectType<Value>) {
return input(type);
} else if (type is GraphQLUnionType<Value>) {
return union(type);
} else if (type is GraphQLListType) {
return list(type);
} else if (type is GraphQLNonNullType<Value, Serialized>) {
return nonNullable(type);
} else {
throw Exception(
'Could not cast $this ($runtimeType) as a typical GraphQLType.',
);
}
}