For AI agents: a documentation index is available at /llms.txt
Skip to main content

buildOperation()

function buildOperation(
name,
args,
fields,
argTypes?,
operation?): object;

Builds a parameterized GraphQL mutation document and its accompanying variables payload. Argument values are passed as GraphQL variables rather than interpolated into the query string, which lets the server coerce and validate them by type (including enums and input objects) and keeps the operation document constant across calls.

Parameters

ParameterTypeDefault valueDescription
namestringundefinedThe mutation field name, eg goto.
argsRecord<string, unknown> | nullundefinedArgument values keyed by argument name. undefined values are dropped. Pass null when the mutation takes no args.
fieldsstringundefinedThe selection set for the mutation's response.
argTypesRecord<string, string>{}Map of argument name → GraphQL type (eg String!), used to declare the operation's variables. Sourced from ARG_TYPES.
operation"mutation" | "subscription"'mutation'The GraphQL operation type. Defaults to mutation; pass subscription to build a streaming operation.

Returns

object

NameType
querystring
variablesRecord<string, unknown>