Wp-graphql: Remove clientMutationId as a required field for mutations

Created on 20 Jan 2020  路  4Comments  路  Source: wp-graphql/wp-graphql

CC: @henrikwirth


The clientMutationId was a field required by Relay 1, and part of the Relay spec when WPGraphQL first began implementing mutations.

The clientMutationId isn't commonly found anymore in new GraphQL APIs, and libraries such as Apollo don't have any need for it. It seems like it's requirement causes more confusion than anything.

We can either:

  • Remove the field altogether from mutation inputs and payloads
  • Leave the field, but make it nullable, (currently it's a non-null input)

I think I'm leaning toward the latter. Leave it there, as it's not hurting anything by existing, and it can still have utility for logging things, etc.

Breaking change

If we change the field by removing it or making it nullable, this will be a breaking change. Depending on how folks have written mutations, this could break their mutations altogether.

For example, the following mutation would not validate and therefore not execute:

mutation CreatePost($clientMutationId: String!, $title: String) {
  createPost(input: {clientMutationId: $clientMutationId, title: $title}) {
    post {
      id
      title
    }
  }
}
Actionable Breaking Change API Mutations

Most helpful comment

Ah, sorry! I forgot for a moment of how the type system checks worked. A breaking change indeed, a good one though.

All 4 comments

Keeping optional would keep back-compact and it wouldn't annoy newcomers. Seem the best of both worlds.

As described in the following examples:

To make it nullable seems to be the right way for me.

@renatonascalves it _technically_ is a breaking change, depending on how you were writing your mutations.

My example above shows one that would break, because it would attempt to validate ClientMutationId input as a nonNull, but that wouldn't match and validation would stop before execution.

We can document this change, and it would be a minor update for folks, but a breaking change nonetheless.

Ah, sorry! I forgot for a moment of how the type system checks worked. A breaking change indeed, a good one though.

Was this page helpful?
0 / 5 - 0 ratings