@index

Specifies the name of the index used to collate documents of the current type, instead of a index named after the field’s name.

Location

Fields within a Query type.

Arguments

Argument Type Required Description

name

String

Yes

The name for the database index to use for this GraphQL query field.

Description

The @index directive controls the name of the underlying database index for the annotated field. By default, the GraphQL API uses the name of the query field as the name of the index within the database.

Example

Given the following GraphQL schema:

type User {
  name: String
}

type Query {
  allUsers: [User!] @index(name: "all_users")
}

The database indexes would be:

Paginate(Indexes())
{ data: [ Index("all_users") ] }

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!