Each object defined in type definitions will have a Query field generated for it. Each Query field accepts two arguments:
-
where
: Used to specify the [schema-filtering] which should be applied whilst querying the data -
options
: Used to specify the options for [schema-sorting] and [schema-pagination]
Given the following type definitions:
type Post {
id: ID! @id
content: String!
creator: User @relationship(type: "HAS_POST", direction: IN)
}
type User {
id: ID! @id
name: String
posts: [Post] @relationship(type: "HAS_POST", direction: OUT)
}
The following Query fields will be automatically generated:
type Query {
posts(where: PostWhere, options: PostOptions): [Post!]!
users(where: UserWhere, options: UserOptions): [User!]!
countPosts(where: PostWhere): Int!
usersCount(where: UserWhere): Int!
}
The following Query will return all Users, returning their ID and name.
query {
users {
id
name
}
}
The following Query will return all Users, returning the content which they have posted.
query {
users {
posts {
content
}
}
}
The following Query will count all users and return a number.
query {
usersCount
}
See [schema-filtering] for details on how data can be filtered whilst querying.