whenMaybe<O> method

O whenMaybe<O>({
  1. O enum_(
    1. GraphQLEnumType<Json>
    )?,
  2. O scalar(
    1. GraphQLScalarType<Json, Object?>
    )?,
  3. O object(
    1. GraphQLObjectType<Json>
    )?,
  4. O input(
    1. GraphQLInputObjectType<Json>
    )?,
  5. O union(
    1. GraphQLUnionType<Json>
    )?,
  6. O list(
    1. GraphQLListType
    )?,
  7. O nonNullable(
    1. GraphQLNonNullType<Json, Object?>
    )?,
  8. required O orElse(
    1. GraphQLType
    ),
})
inherited

Similar to when, but with optional arguments and a required default case orElse, which is executed when none of the provided functions match this

Implementation

O whenMaybe<O>({
  O Function(GraphQLEnumType<Value>)? enum_,
  O Function(GraphQLScalarType<Value, Serialized>)? scalar,
  O Function(GraphQLObjectType<Value>)? object,
  O Function(GraphQLInputObjectType<Value>)? input,
  O Function(GraphQLUnionType<Value>)? union,
  O Function(GraphQLListType)? list,
  O Function(GraphQLNonNullType<Value, Serialized>)? nonNullable,
  required O Function(GraphQLType) orElse,
}) {
  return when(
    scalar: scalar ?? orElse,
    object: object ?? orElse,
    input: input ?? orElse,
    list: list ?? orElse,
    nonNullable: nonNullable ?? orElse,
    enum_: enum_ ?? orElse,
    union: union ?? orElse,
  );
}