Skip to main content

Enums

Enums are text values which are restricted to a set of predefined variants. Their behavior is similar to scalars and they don't have a nested fields.

GraphQL Specification

They require a unique name and a set of entries mapping their string representation to the Dart value obtained after parsing.

"""The error reason on a failed sign up attempt"""
enum SignUpError {
usernameTooShort,
usernameNotFound,
wrongPassword,
passwordTooSimple,
}
import 'package:leto/leto.dart';

final signUpErrorGraphQLType = enumTypeFromStrings(
'SignUpError',
[
'usernameTooShort',
'usernameNotFound',
'wrongPassword',
'passwordTooSimple',
],
description: 'The error reason on a failed sign up attempt',
);


// Or with code generation

/// The error reason on a failed sign up attempt
()
enum SignUpError {
usernameTooShort,
usernameNotFound,
wrongPassword,
passwordTooSimple,
}