schema – Partial Graphql type

In typescript you can do Partial<T> to extends a T but make all of its fields optional — I am wondering how can you do the same thing in a Graphql schema.

Say you have a mutation type field that takes a book input type,

input BookInput {
  id: !ID
  title: !String
  author: !String

type Mutation {
  addBook (book: BookInput): Book  
  updateBook (id: ID, book: BookInput): Book

The problem is when updating a Book, not all the fields(fields in BookInput) in the book argument are required

How can I do something like this, like in Typescript

updateBook: (id: ID, book: Partial<BookInput>): Book

Read more here: Source link