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
}
}
}
addBook(title: "Fox in Socks", author: "Dr. Seuss") {
title
author {
name
}
}
}
Defining interface
interface MutationResponse {
code: String!
success: Boolean!
message: String!
book: Book
}
code: String!
success: Boolean!
message: String!
book: Book
}
Sample code can be found here.
https://github.com/mitzenjeremywoo/graphql-review-ts
Comments