Schema File
The schema.graphql
is written in the GraphQL schema definition language and describes the layout of the data that will be indexed.
Entities are defined using the type
keyword, and fields are defined within the entity using the field_name: field_type
syntax. Basic scalar types such as String
, Int
, Float
, Boolean
, Bytes
, and ID
are supported, as well as custom types defined in the schema. Note that the ID
type is used to represent unique identifiers and is serialized as a string.
The following example demonstrates how to define a simple schema that holds books and author information:
type Book {
id: ID!
title: String!
author: Author!
}
type Author {
id: ID!
name: String!
books: [Book!]! @derivedFrom(field: "author")
}
In the example above, the Book
entity has three fields: id
, title
, and author
. The author
field is of type Author
, which is another entity defined in the schema. The Author
entity has three fields: id
, name
, and books
. The books
field is a list of Book
entities that are associated with the author. The @derivedFrom
directive is used to specify that the books
will not be set by mappings but will be derived from the author
field in the Book
entity.
Updated 18 days ago