Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 3

GraphQL Interface without fields leads to error in mutation

Solved! Go to Solution.

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

2 Replies
Highlighted
Solution
Community Manager
Message 2 of 3

Re: GraphQL Interface without fields leads to error in mutation

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.

Highlighted
Copilot Lvl 2
Message 3 of 3

Re: GraphQL Interface without fields leads to error in mutation

Thanks a lot,

that does the job!

 

Cheers,

Lars