New "many" mutations: `updatePosts` / `createPosts`
See original GitHub issueCurrently we have these:
Singular | Many |
---|---|
createPost |
❌ |
Post |
allPosts |
updatePost |
❌ |
deletePost |
deletePosts |
The missing mutations would be createPosts
& updatePosts
to complete that table.
The input parameters would be the same for the Many case as for the Singular case, but as an Array (and likewise for the return type):
input PostsUpdateInput {
id: ID!
data: PostUpdateInput
}
input PostsCreateInput {
data: PostCreateInput
}
type Mutation {
updatePosts(data: [PostsUpdateInput]): Posts
createPosts(data: [PostsCreateInput]): Posts
}
Which you’d then execute like so:
mutation {
createPosts(data: [
{ data: { title: "Hello" } },
{ data: { title: "A post" } }
]) {
id
title
}
}
mutation {
updatePosts(data: [
{ id: "abc123", data: { title: "Hello" } },
{ id: "def456", data: { title: "A post" } }
]) {
id
title
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
GraphQL Mutations | Contember
Contember offers advanced mutations for data modification. ... createPost(data: PostCreateInput!) ... Using a create mutation you can create new records.
Read more >Using nested mutations - GraphQL API for WordPress
The query below executes a standard mutation, using the mutation field updatePost from the root type: mutation { updatePost(id: 5, title: "New title")...
Read more >Nested Mutations - Lighthouse PHP
Nested Mutations. Lighthouse allows you to create, update or delete models and their associated relationships, all in one single mutation.
Read more >Using GraphQL with Python – A Complete Guide
To do so we will follow the same pattern. First, we will update the schema and add a new mutation called updatePost ....
Read more >Supporting opt-in nested mutations in GraphQL
mutation { updatePost(id: 5, title: "New title") { title } } ... the mutation fields ( createPost and updatePost ) can only appear...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m +1 on this idea. I think the
deleteMutation
anddeleteManyMutation
methods on theList
class give us the pattern for how to implement these mutations.At the moment the
deletePosts
mutation runs each of the delete operations independently, so even if one fails for some reason (e.g. validation), the others still get deleted. This is by design and is believed to be correct.I just started using Keystone and when I use this code below in the image, it work and create one user but as long I use the second code it won’t work
https://prnt.sc/u97b18
https://prnt.sc/u97bmq