Queries

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 Filtering which should be applied whilst querying the data

  • options: Used to specify the options for Sorting and Pagination

1. Example

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!]!
}

1.1. Querying for all Users

The following Query will return all Users, returning their ID and name.

query {
    users {
        id
        name
    }
}

1.2. Query for all Users' Posts

The following Query will return all Users, returning the content which they have posted.

query {
    users {
        posts {
            content
        }
    }
}

1.3. Filtering

See Filtering for details on how data can be filtered whilst querying.