I'm working on a Relay-compliant GraphQL schema and would like to include a mutation that takes an input object that requires either one argument (the ID of a record) or two other arguments (a record number and a catalog number for the record). I'm using Python and the Graphene library. Here's an snippet of the current input object that doesn't allow for the ID to be used instead of the number / catalog:
class CreateRecord(relay.ClientIDMutation):
"The parameters of a newly created record."
# Relay-compliant mutations need to specify an input class.
class Input:
"The available inputs for the CreateRecord mutation."
part_id = graphene.Int(description='The ID of the record.')
part_number = graphene.String(description='The record number.',
required=True)
catalog = graphene.String(description='The catalog of the record.',
required=True)
I've looked into interfaces and unions in order to make this happen, but haven't had any luck so far. Without a more flexible input object, I'll likely need to create another mutation (like CreateRecordUsingID
). Is there a way to achieve this, or more generally to support this functionality in GraphQL schemas?