GraphQL API
Keystone generates a CRUD (create, read, update, delete) GraphQL API based on the schema definition provided in the system config.
Consider the following system definition:
import { config, createSchema, list } from '@keystone-next/keystone/schema';import { text } from '@keystone-next/fields';export default config({lists: createSchema({User: list({ fields: { name: text() } }),}),/* ... */});
This system will generate the following GraphQL API.
Note: The names and types of the generated queries and mutations are based on the names of the lists and fields in the system config.
type Query {User(where: UserWhereUniqueInput!): UserallUsers(where: UserWhereInput, search: String, orderBy: [UserOrderByInput!]! = [], first: Int, skip: Int! = 0): [User]_allUsersMeta(where: UserWhereInput, search: String, orderBy: [UserOrderByInput!]! = [], first: Int, skip: Int! = 0): _QueryMeta}type Mutation {createUser(data: UserCreateInput): UsercreateUsers(data: [UsersCreateInput]): [User]updateUser(id: ID!, data: UserUpdateInput): UserupdateUsers(data: [UsersUpdateInput]): [User]deleteUser(id: ID!): UserdeleteUsers(ids: [ID!]): [User]}type User {id: ID!name: String}input UserWhereInput {AND: [UserWhereInput!]OR: [UserWhereInput!]id: IDid_not: IDid_lt: IDid_lte: IDid_gt: IDid_gte: IDid_in: [ID!]id_not_in: [ID!]name: Stringname_not: Stringname_contains: Stringname_not_contains: Stringname_starts_with: Stringname_not_starts_with: Stringname_ends_with: Stringname_not_ends_with: Stringname_i: Stringname_not_i: Stringname_contains_i: Stringname_not_contains_i: Stringname_starts_with_i: Stringname_not_starts_with_i: Stringname_ends_with_i: Stringname_not_ends_with_i: Stringname_in: [String]name_not_in: [String]}input UserWhereUniqueInput {id: ID}input UserOrderByInput {id: OrderDirectionname: OrderDirection}enum OrderDirection {ascdesc}input UserUpdateInput {name: String}input UsersUpdateInput {id: ID!data: UserUpdateInput}input UserCreateInput {name: String}input UsersCreateInput {data: UserCreateInput}type _QueryMeta {count: Int}
Queries
User
type Query {User(where: UserWhereUniqueInput!): User}input UserWhereUniqueInput {id: ID}type User {id: ID!name: String}
allUsers
type Query {allUsers(where: UserWhereInput, search: String, orderBy: [UserOrderByInput!]! = [], first: Int, skip: Int! = 0): [User]}input UserWhereInput {AND: [UserWhereInput!]OR: [UserWhereInput!]id: IDid_not: IDid_lt: IDid_lte: IDid_gt: IDid_gte: IDid_in: [ID!]id_not_in: [ID!]name: Stringname_not: Stringname_contains: Stringname_not_contains: Stringname_starts_with: Stringname_not_starts_with: Stringname_ends_with: Stringname_not_ends_with: Stringname_i: Stringname_not_i: Stringname_contains_i: Stringname_not_contains_i: Stringname_starts_with_i: Stringname_not_starts_with_i: Stringname_ends_with_i: Stringname_not_ends_with_i: Stringname_in: [String]name_not_in: [String]}input UserOrderByInput {id: OrderDirectionname: OrderDirection}enum OrderDirection {ascdesc}type User {id: ID!name: String}
usersCount
type Query {usersCount(where: UserWhereInput! = {}): Int!}input UserWhereInput {AND: [UserWhereInput!]OR: [UserWhereInput!]id: IDid_not: IDid_lt: IDid_lte: IDid_gt: IDid_gte: IDid_in: [ID!]id_not_in: [ID!]name: Stringname_not: Stringname_contains: Stringname_not_contains: Stringname_starts_with: Stringname_not_starts_with: Stringname_ends_with: Stringname_not_ends_with: Stringname_i: Stringname_not_i: Stringname_contains_i: Stringname_not_contains_i: Stringname_starts_with_i: Stringname_not_starts_with_i: Stringname_ends_with_i: Stringname_not_ends_with_i: Stringname_in: [String]name_not_in: [String]}input UserOrderByInput {id: OrderDirectionname: OrderDirection}enum OrderDirection {ascdesc}type _QueryMeta {count: Int}
Mutations
createUser
type Mutation {createUser(data: UserCreateInput): User}input UserCreateInput {name: String}type User {id: ID!name: String}
createUsers
type Mutation {createUsers(data: [UsersCreateInput]): [User]}input UsersCreateInput {data: UserCreateInput}input UserCreateInput {name: String}type User {id: ID!name: String}
updateUser
type Mutation {updateUser(id: ID!, data: UserUpdateInput): User}input UserUpdateInput {name: String}type User {id: ID!name: String}
updateUsers
type Mutation {updateUsers(data: [UsersUpdateInput]): [User]}input UsersUpdateInput {id: ID!data: UserUpdateInput}input UserUpdateInput {name: String}type User {id: ID!name: String}
deleteUser
type Mutation {deleteUser(id: ID!): User}type User {id: ID!name: String}
deleteUsers
type Mutation {deleteUsers(ids: [ID!]): [User]}type User {id: ID!name: String}