1

I have some problems when using Fauna and GraphQL

When I use GraphQL to update data, all parameters are required

For example


// Schema

type User {
    username: String!
    password: String!
    phone: String!
}

// Mutation

mutation {
    updateUser(id: "xxxxx", {"phone": "+886 110220330"}){
        username,
        phone
    }
}

// Error

But I only want to update the phone data this time, how can I skip other parameters?

Although it can solve the problem when I delete the Not null of all attributes in User type,

But it doesn't look like a good way and safe


// after

//  Schema

type User {
    username: String
    password: String
    phone: String
}

1 Answers1

0

There is a preview feature that you can use by adding a header to your GraphQL query.

X-Schema-Preview: partial-update-mutation

Once you do this, you will have access to a new mutation called partialUpdateUser which will make all of the input values optional.

See the docs for more information: https://docs.fauna.com/fauna/current/api/graphql/previews/

ptpaterson
  • 9,131
  • 4
  • 26
  • 40