graphql-server.impl

Internal implementation details for GraphQL resolver handling.

->argument-type

(->argument-type schema _ children _)

Extracts the argument schema from a resolver function schema.

Walks a Malli :=> schema to extract the second argument (args) from the :cat. Used to get the schema for coercing GraphQL arguments.

->return-type

(->return-type schema _ children _)

Extracts the return type schema from a resolver function schema.

Walks a Malli :=> schema to extract the return type. Used to get the schema for encoding resolver return values.

coerce-args

(coerce-args arg-schema f)

Wraps a resolver function with Malli argument coercion.

Takes an argument schema and a 3-arity resolver function, returning a wrapped function that decodes and coerces the second argument (GraphQL args) according to the schema.

Arguments are decoded using decoding-transformer which: - Converts camelCase keys to kebab-case keywords - Converts string enum values to namespaced keywords (if schema uses them) - Applies standard string->type coercions (e.g., string to UUID)

On coercion failure, returns a map with :errors key containing humanized validation errors. This allows the caller to handle errors appropriately (e.g., convert to GraphQL error format).

encode

(encode data schema)

Encodes application data into GraphQL output format according to the given Malli schema.

Applies enum and key transformations using encoding-transformer.

make-stream-encoder

(make-stream-encoder return-type-schema)

Creates an encoder function for subscription streamed values.

Takes a return type schema (from the :=> function schema) and returns a function that encodes individual values. Handles :maybe and :vector wrappers by encoding against the unwrapped item schema.

Used by graphql-server.core/defstreamer to encode each value as it flows through the subscription channel, using the same transformation logic as resolver encoding: - kebab-case -> camelCase key transformation - Enum encoding (keywords -> SCREAMING_SNAKE_CASE) - Type tagging for unions/interfaces

merge-tag-with-type

(merge-tag-with-type schema)

Creates a function that tags data with its concrete GraphQL type.

Takes a Malli schema (typically a :multi schema representing a GraphQL union or interface) and returns a function. This returned function, when given a data instance, uses the original schema’s dispatch function to determine the instance’s concrete type and returns the corresponding GraphQL type name (as a keyword).

This is primarily used by Lacinia’s tag-with-type to resolve concrete types for unions and interfaces at query time.

wrap-resolver-with-encoding

(wrap-resolver-with-encoding resolver return-type-schema)

Wraps a resolver function to automatically encode its return value.

Takes a resolver function and a return type schema. Returns a new resolver function that: 1. Calls the original resolver 2. Encodes the result using the return type schema (including Lacinia type tags) 3. Returns the encoded result

The encoding transformer automatically applies Lacinia type tags to all nested :map and :multi types that have :graphql/type or :graphql/interface properties. If the result is nil, returns nil without encoding. If the result is a collection, encodes each element with the unwrapped item schema.