@collection
directive
Specifies the name of the Fauna collection to use, instead of an automatically-created collection name based on the GraphQL type.
Arguments
Argument | Type | Required | Description |
---|---|---|---|
|
String |
Yes |
The name for the database collection to use for this GraphQL type. |
Description
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.
Example
Given the following GraphQL schema:
type User @collection(name: "users") {
name: String
}
The database collections would be:
Paginate(Collections())
{ 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!