The Grafbase Database is deprecated. Use connectors to federate your existing data sources.
The Grafbase Database provides mutations to create, update, and delete entries for any configured model. However, if you wanted to execute multiple mutations, you needed to conduct separate mutations.
We're excited to announce that Grafbase Database now supports batch mutations!
Batch mutations are engineered to function in a manner akin to their single mutation equivalents.
The examples below use the following schema:
import { g } from '@grafbase/sdk'
g.model('Post', {
title: g.string(),
slug: g.string().unique(),
})
This will automatically generate additional GraphQL mutations for all database models:
mutation {
postUpdateMany(input: [PostUpdate!]!): PostUpdateManyPayload
postCreateMany(input: [PostCreate!]!): PostCreateManyPayload
postDeleteMany(input: [PostDelete!]!): PostDeleteManyPayload
}
To create multiple entries at once, passed an array objects to input
:
mutation {
postCreateMany(
input: [
{ input: { title: "Batch", slug: "batch" } }
{ input: { title: "Operations", slug: "operations" } }
]
) {
postCollection {
id
title
slug
}
}
}
To update multiple entries at once, passed an array objects to input
that contains by
and new input
values:
mutation {
postUpdateMany(
input: [
{ by: { id: "..." }, input: { title: "Batch!" } }
{ by: { slug: "operations" }, input: { title: "Operations!" } }
]
) {
postCollection {
id
title
slug
}
}
}
To delete multiple entries at once, passed an array objects to input
that contains the by
values:
mutation {
postDeleteMany(input: [{ by: { id: "..." } }, { by: { slug: "batch" } }]) {
deletedIds
}
}
- Fixes an issue introduced in
0.26.1
that would cause an infinite reinstallation of dependencies if package.json was located in thegrafbase/
directory. - Change the working directory in which resolver builds take place allowing them to import files relative to the project directory.
- Fixes
allOf
schema support when using the@openapi
connector. - JSON scalars will now accept any literal
Value
in documents. - Added the missing description field to
__Schema
in introspection. - Fixes the
__type
field in introspection. - The
@graphql
connector now pulls in an objects interfaces correctly. - Type conditions on inline & fragment spreads now match interfaces correctly.
- Type conditions on unions will now match if the condition is the union type.
- For update mutations, like
postUpdate
, nullable fields can now be set tonull
. Previously, those updates would be ignored. - Improved support for v2 of the OpenAPI specification.
We'd love to hear your feedback and ideas, so join us on Discord.