Specifies the name of a Fauna user-defined function to use instead of a default field value resolver.


Fields within the Query or Mutation types.


Argument Type Required Default Description




The field’s name.

The name for the resolver function.





When true, the resolver accepts three arguments, size, afterCursor, and beforeCursor, and then returns a Page of results. See the Example below, and the UDF that returns a database page.


The @resolver directive marks a Query or Mutation that has an associated user-defined function in the database. Queries to fields annotated with the @resolver directive are resolved by calling the underlying user-defined function, which is a Fauna Query Language Lambda function.

The name of the function is controlled by the name argument, which defaults to the name of the field. The paginated argument controls pagination support for the values returned by the user-defined function.

When a schema is imported into the GraphQL API, resolvers for your schemas fields are automatically generated. When you apply the @resolver directive to a query field, the named resolver is used instead of the automatically-generated resolver for the field.

The GraphQL API always passes arguments to resolver’s user-defined function as an array. Even if your schema only ever passes one argument to your resolver, you must implement the resolver’s user-defined function to accept the arguments as an array. See the function_names function in the Example section.

User-defined functions cannot be created directly with GraphQL queries. When you import a schema that refers to a resolver that does not exist, the GraphQL API creates "stub" functions that throw resolver-specific errors reminding you to implement them. For example, if your GraphQL schema referred to an unimplemented resolver called prune_order, the GraphQL API would create the following function:

  ref: Function("prune_order"),
  ts: 1613415645650000,
  name: 'prune_order',
  data: {
    gql: {
      ts: Time("2021-02-15T19:00:45.526Z"),
      meta: {
        location: 'Mutation',
        field: {
          name: 'pruneOrder',
          directives: [
              name: 'resolver',
              args: { name: 'prune_order', paginated: false }
          type: { NotNull: { Named: 'Order' } },
          arguments: [
            { name: 'customerId', type: { NotNull: { Named: 'ID' } } }
  body: Query(Lambda("_", Abort("Function prune_order was not implemented yet. Please access your database and provide an implementation for the prune_order function.")))

To implement the resolver, you should use the Update function to replace the function’s body field definition.

Any functions created by the GraphQL API include a data field that contains metadata about the resolver: if you delete the function and recreate it with the desired body function, you would lose the GraphQL metadata, which would prevent the resolver from functioning.

For more information, see User-defined functions.


The following two FQL queries each create a function:

  name: "say_hello",
  body: Query(Lambda([], "hello"))
  name: "function_names",
  body: Query(Lambda(["size", "afterCursor", "beforeCursor"],
        Select("name", Get(Var("ref")))

The first function, called say_hello, only returns the string hello. The second function, called function_names, returns the list of functions defined in the database. For a more in-depth example, see A UDF that returns a database page.

We can use these function in GraphQL queries by using the following schema:

type Query {
  sayHello: String! @resolver(name: "say_hello")
  functionNames: [String!] @resolver(name: "function_names", paginated: true)

With the functions and the schema in place, we can call the first function with this GraphQL query:


which should produce the following response:

  "data": {
    "sayHello": "hello"

Calling the second function would look like this:

  functionNames {

And the response would look like:

  "data": {
    "functionNames": {
      "data": [

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!