whenOrNull<O> method

O? whenOrNull<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?>
    )?,
})
inherited

Similar to when, but with optional arguments. Returns null when none of the provided functions match this

Implementation

O? whenOrNull<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,
}) {
  O? orElse(GraphQLType _) {
    return null;
  }

  return when(
    scalar: scalar ?? orElse,
    object: object ?? orElse,
    input: input ?? orElse,
    list: list ?? orElse,
    nonNullable: nonNullable ?? orElse,
    enum_: enum_ ?? orElse,
    union: union ?? orElse,
  );
}