swell/schema
Types
Resolver context - will contain request context, data loaders, etc.
pub type Context {
Context(
data: option.Option(value.Value),
arguments: dict.Dict(String, value.Value),
variables: dict.Dict(String, value.Value),
)
}
Constructors
-
Context( data: option.Option(value.Value), arguments: dict.Dict(String, value.Value), variables: dict.Dict(String, value.Value), )
GraphQL Input Field (for InputObject types)
pub opaque type InputField
Field resolver function type
pub type Resolver =
fn(Context) -> Result(value.Value, String)
Values
pub fn argument(
name: String,
arg_type: Type,
description: String,
default_value: option.Option(value.Value),
) -> Argument
pub fn argument_description(arg: Argument) -> String
Get argument description
pub fn boolean_type() -> Type
pub fn context(data: option.Option(value.Value)) -> Context
Helper to create a context without arguments or variables
pub fn context_with_variables(
data: option.Option(value.Value),
variables: dict.Dict(String, value.Value),
) -> Context
Helper to create a context with variables
pub fn enum_value(name: String, description: String) -> EnumValue
pub fn enum_value_description(enum_value: EnumValue) -> String
Get enum value description
pub fn field(
name: String,
field_type: Type,
description: String,
resolver: fn(Context) -> Result(value.Value, String),
) -> Field
pub fn field_name(f: Field) -> String
pub fn field_with_args(
name: String,
field_type: Type,
description: String,
arguments: List(Argument),
resolver: fn(Context) -> Result(value.Value, String),
) -> Field
pub fn float_type() -> Type
pub fn get_argument(
ctx: Context,
name: String,
) -> option.Option(value.Value)
Helper to get an argument value from context
pub fn get_field(
t: Type,
field_name: String,
) -> option.Option(Field)
pub fn get_input_fields(t: Type) -> List(InputField)
Get all input fields from an InputObjectType
pub fn get_mutation_type(s: Schema) -> option.Option(Type)
pub fn get_subscription_type(s: Schema) -> option.Option(Type)
pub fn get_union_type_resolver(
t: Type,
) -> fn(Context) -> Result(String, String)
Get the type resolver function from a union type. The type resolver is called at runtime to determine which concrete type a union value represents, based on the data in the context. Returns a default resolver that always errors for non-union types. This is primarily used internally for union type normalization.
pub fn get_variable(
ctx: Context,
name: String,
) -> option.Option(value.Value)
Helper to get a variable value from context
pub fn inner_type(t: Type) -> option.Option(Type)
Get the inner type from a wrapping type (List or NonNull)
pub fn input_field(
name: String,
field_type: Type,
description: String,
default_value: option.Option(value.Value),
) -> InputField
pub fn input_field_description(input_field: InputField) -> String
Get input field description
pub fn input_field_name(input_field: InputField) -> String
Get input field name
pub fn input_object_type(
name: String,
description: String,
fields: List(InputField),
) -> Type
pub fn is_input_object(t: Type) -> Bool
pub fn is_non_null(t: Type) -> Bool
pub fn named_type_name(t: Type) -> String
Get the named (base) type name, unwrapping List and NonNull wrappers. This is used for fragment type condition matching and __typename where we need the concrete type name without modifiers.
pub fn resolve_field(
field: Field,
ctx: Context,
) -> Result(value.Value, String)
pub fn resolve_union_type(
t: Type,
ctx: Context,
) -> Result(Type, String)
Resolve a union type to its concrete type using the type resolver
pub fn resolve_union_type_with_registry(
t: Type,
ctx: Context,
type_registry: dict.Dict(String, Type),
) -> Result(Type, String)
Resolve a union type using a canonical type registry This looks up the concrete type by name from the registry instead of from the union’s possible_types, ensuring we get the most complete type definition
pub fn schema_with_subscriptions(
query_type: Type,
mutation_type: option.Option(Type),
subscription_type: option.Option(Type),
) -> Schema
pub fn string_type() -> Type
pub fn type_description(t: Type) -> String
pub fn type_kind(t: Type) -> String
Get the kind of a type as a string for introspection