Skip to content

Latest commit

 

History

History
83 lines (63 loc) · 1.57 KB

queries.adoc

File metadata and controls

83 lines (63 loc) · 1.57 KB

Queries

Each object defined in type definitions will have a Query field generated for it. Each Query field accepts two arguments:

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!]!
    countPosts(where: PostWhere): Int!
    usersCount(where: UserWhere): Int!
}

Querying for all Users

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

query {
    users {
        id
        name
    }
}

Query for all Users' Posts

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

query {
    users {
        posts {
            content
        }
    }
}

Counting all Users

The following Query will count all users and return a number.

query {
    usersCount
}

Filtering

See [schema-filtering] for details on how data can be filtered whilst querying.