Queries
This is the documentation of the GraphQL Library version 6. For the long-term support (LTS) version 5, refer to GraphQL Library version 5 LTS. |
Type definitions
Quries on this page assume the following type definitions:
type Post @node {
id: ID! @id
content: String!
creator: User! @relationship(type: "HAS_POST", direction: IN, properties: "PostedAt")
createdAt: DateTime!
}
type User @node {
id: ID! @id
name: String!
age: Int!
posts: [Post!]! @relationship(type: "HAS_POST", direction: OUT, properties: "PostedAt")
friends: [User!]! @relationship(type: "FRIENDS_WITH", direction: OUT)
}
type PostedAt @relationshipProperties {
date: DateTime
}
For which the following query fields are generated:
type Query {
posts(where: PostWhere, sort: [PostSort!]!, limit: Int, offset: Int,): [Post!]!
postsAggregate(where: PostWhere): PostAggregationSelection!
users(where: UserWhere, sort: [UserSort!]!, limit: Int, offset: Int,): [User!]!
usersAggregate(where: UserWhere): UserAggregationSelection!
}
Writing queries
Based on the type definitions, here are two examples of how to write queries for reading or retrieving values:
Return all User nodes from their ID and name
query {
users {
id
name
}
}
Query User with name "Jane Smith" and their posts
query {
users(where: { name_EQ: "Jane Smith" }) {
id
name
posts {
content
}
}
}