djangographqlgraphene-pythongraphene-django

Django graphene - mutation input without typing


In mutation, I just need to save the event name and its payload that might differ and I do not need any validation for it. How can I say graphene that I just need to accept an object?

class SendEvent(MutationMixin, relay.ClientIDMutation):
    class Input:
        event = graphene.String(required=True)
        payload = # any object

Solution

  • I hope you can use the GenericScalar(...)

    from graphene.types.generic import GenericScalar
    
    
    class SendEvent(MutationMixin, relay.ClientIDMutation):
        class Input:
            event = graphene.String(required=True)
            payload = GenericScalar(required=True)