GraphQL Interface without fields leads to error in mutation

Hi,

when using the mutation addLabelsToLabelable it returns two fields

  • clientMutationId (that one is always null in my case)
  • labelable

I would like to use labelable since I label a PullRequest, which implement the Labelable interface. But that interface has no fields. So I cannot give any field in the mutation, which leads to the error:

Field must have selections (field 'labelable' returns Labelable but has no selections. Did you mean 'labelable { ... }'?)

So the only “workaround” is to use  clientMutationId  instead and receive the null. But I would like to receive e.g. the title of the labeled Pull Request. Is that possible?

Thanks and Cheers,

Lars

From what I understand, you should be able to use the same ... on PullRequest syntax that you would use in a query that returns multiple object types. So something like this:

mutation {
  addLabelsToLabelable(input: {clientMutationId: "foo", labelableId: "foo", labelIds: [1]}) {
    labelable {
      ... on PullRequest {
        title
      }
    }
  }
}

Let us know if you have more questions.

1 Like

Thanks a lot,

that does the job!

Cheers,

Lars

1 Like