graphql mutation getting started

 Defining the mutation 

type Mutation { addBook(title: String, author: String): Book }

Mutation graphql execution

For executing the graphql as a clien you can use this. And the expected response is title, author's name as shown below

mutation CreateBook {
addBook(title: "Fox in Socks", author: "Dr. Seuss") {
title
author {
name
}
}
}

Defining interface

interface MutationResponse {
code: String!
success: Boolean!
message: String!
book: Book
}

Sample code can be found here.

https://github.com/mitzenjeremywoo/graphql-review-ts







Comments

Popular posts from this blog

gemini cli getting file not defined error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

vllm : Failed to infer device type