You are viewing documentation for a previous version of this software.

Switch to the latest stable version.

GraphQLEnum


ENUM

GraphQLEnum

Swift
1public enum GraphQLEnum<T>: CaseIterable, Equatable, RawRepresentable
2where T: RawRepresentable & CaseIterable, T.RawValue == String

A generic enum that wraps a generated enum from a GraphQL Schema.

GraphQLEnum provides an __unknown case that is used when the response returns a value that is not recognized as a valid enum case. This is usually caused by future cases added to the enum on the schema after code generation.

Cases

case(_:)

Swift
1case `case`(T)

A recognized case of the wrapped enum.

__unknown(_:)

Swift
1case __unknown(String)

An unrecognized value for the enum. The associated value exposes the raw String data from the response.

Properties

value

Swift
1public var value: T?

The underlying enum case. If the value is __unknown, this will be nil.

rawValue

Swift
1public var rawValue: String

allCases

Swift
1public static var allCases: [GraphQLEnum<T>]

A collection of all known values of the wrapped enum. This collection does not include the __unknown case.

Methods

init(_:)

Swift
1public init(_ caseValue: T)

init(rawValue:)

Swift
1public init(rawValue: String)

Parameters

NameDescription
rawValueThe raw value to use for the new instance.
Feedback

Edit on GitHub

Forums