Introducing a new way to review your PRs.

Read the announcement

appwrite / sdk-for-react-native

[READ ONLY] Official Appwrite React Native SDK 💙 ⚛︎

View on GitHub

24 documents · Updated Nov 18, 2026

docs / functions-and-graphql

Functions and GraphQL

The Functions and GraphQL services let an application run server-side function work and ask Appwrite for data through GraphQL. Function calls return execution records that can be checked later, while GraphQL calls return the API result for a query or mutation. This page is a child of Data, files, and execution services; see also Databases and TablesDB records and Storage file lifecycle for the other data services.

Function execution

The Functions service starts a function with an HTTP-like request and returns an execution record. The request can carry a body, path, method, and headers, so the function can receive the same kinds of inputs as a web request.

Execution requests

createExecution requires a function ID. Its optional inputs control the request sent to the function and when the work runs.

Input groupPurpose
Function IDSelects the function to run.
Body, path, method, and headersSupplies the function request. The path can include query parameters.
Async flagLets the function run in the background instead of waiting for its work to finish.
Scheduled timePlaces the execution in the future using an ISO 8601 time.

The returned Execution record is the handle for the work. A caller can use its ID to inspect progress or the final result.

The following flow shows how a request becomes an execution that the caller can inspect.

flowchart LR
    A[Function request] --> B[Function execution]
    B --> C[Initial execution record]
    C --> D[Execution inspection]
    D --> E[Current status and result]

References: src/…/functions.ts• L168-176 src/…/functions.ts• L257-352 src/models.ts• L1152-1225 src/…/execution-method.ts• L1-9

Execution inspection

Execution inspection covers both a single execution and a filtered list of executions for one function. getExecution reads one execution by function ID and execution ID. listExecutions returns an ExecutionList with a total count and matching execution records, and its queries can narrow the records by fields such as status, trigger, duration, or request path.

An execution moves through states such as waiting, processing, completed, failed, or scheduled. The record also describes the trigger, deployment, request, response status, duration, and available logs or errors. Response content is not always present: response details depend on how the execution was started, and logs and errors can be limited by the way the response is returned.

References: src/…/functions.ts• L21-25 src/…/functions.ts• L67-152 src/…/functions.ts• L363-472 src/models.ts• L134-146 src/models.ts• L1152-1225 src/…/execution-status.ts• L1-7 src/…/execution-trigger.ts• L1-5

GraphQL calls

The Graphql service sends a required query object to Appwrite and returns the resulting API response. It separates read work from change work through query and mutation, and each method sends the object to its matching GraphQL endpoint.

Query and mutation requests

The caller supplies the GraphQL operation object as the query input. This object can carry the document and its variables. The service routes read operations through query and write operations through mutation; the selected method determines which GraphQL endpoint Appwrite receives.

CallMain purposeRequired inputReturned value
queryRead data without changing it.GraphQL query object.GraphQL API result.
mutationRequest a change through GraphQL.GraphQL mutation object.GraphQL API result.

The call fails before it is sent when the required query input is missing. Applications should pass the document in the call and then handle the API result as the response for that GraphQL operation.

References: src/…/graphql.ts• L10-67 src/…/graphql.ts• L70-128 docs/…/query.md• L1-15 docs/…/mutation.md• L1-15

API results

GraphQL calls return a promise for the API result rather than an Execution model. This keeps the returned value aligned with the fields requested by the GraphQL document. Function calls instead return a platform-defined execution record because their work can continue after the request that starts it.

These services therefore support two different result paths: GraphQL returns the answer to a data request, while Functions returns a durable reference to server-side work and exposes its later state through inspection.

References: src/…/functions.ts• L168-176 src/…/functions.ts• L363-366 src/…/graphql.ts• L10-18 src/…/graphql.ts• L70-77 src/models.ts• L1152-1225

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the function request inputs aligned with the execution record fields used to inspect request, response, status, and timing data.
  • Keep execution status and trigger values consistent across the returned model, list filters, and exported enum values.
  • Keep the distinction between starting an asynchronous or scheduled execution and reading its later state clear in both service contracts.
  • Keep GraphQL query and mutation inputs mapped to their matching operation and preserve the returned API-result shape.
  • Keep the public service exports and examples aligned when a service method or its required input changes.

Important failure modes

TriggerConsequenceGuard
A function ID or execution ID is missing.The SDK raises an AppwriteException and sends no inspection request.Provide both IDs for single-execution reads and a function ID for lists or new executions.
The GraphQL query input is missing.The SDK raises an AppwriteException before calling the GraphQL endpoint.Pass the GraphQL document in the required query field.
A caller treats an asynchronous or scheduled execution as complete.The first execution record can show only an intermediate status.Use the returned execution ID with getExecution or listExecutions until the work reaches a final state.
A caller expects response bodies, headers, logs, or errors in every execution record.Some diagnostic or response fields are empty or limited.Account for the execution mode and response access rules when reading those fields.
A scheduled time is not a future ISO 8601 time with minute precision.Appwrite rejects the scheduled execution request.Validate the time before creating the execution.

Key files

FileWhy to read it
src/…/functions.tsDefines the lifecycle for starting function work and reading one or many execution records.
src/…/graphql.tsDefines the query and mutation request boundary and their API-result return path.
src/models.tsDescribes the execution record and the list wrapper returned by function inspection.
src/…/execution-status.tsDefines the states an execution can report.
src/…/execution-trigger.tsDefines the sources that can start an execution.
src/index.tsShows the public SDK entry points for Functions, Graphql, and execution value types.
docs/…/query.mdShows the public shape of a GraphQL query call.
docs/…/mutation.mdShows the public shape of a GraphQL mutation call.