@collection directive

Specifies the name of the Fauna collection to use, instead of an automatically-created collection name based on the GraphQL type.

Schema location

This directive is valid in a Type declaration within a GraphQL schema.


Argument Type Required Description




The name for the database collection to use for this GraphQL type.


The @collection directive controls the name of the underlying database collection for the annotated type. By default, the GraphQL API uses the name of a type as the name of the collection in the database.

When a collection with the specified name already exists, the GraphQL API uses that collection. If not, the GraphQL API creates the collection using the specified name.


Given the following GraphQL schema:

type User @collection(name: "users") {
  name: String

The database collections would be:

{ data: [ Collection("users") ] }

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!