Skip to content

Mutation.Field ignores required=True #694

@chanind

Description

@chanind

I recently upgraded from graphene 1.4.1 to 2.0.1, and after the upgrade all mutations are now ignoring required=True. It looks like this is because only name, description, and deprecation_reason are passed through to Field (https://github.com/graphql-python/graphene/blob/master/graphene/types/mutation.py#L80). Is this intentional behavior? If so, what's the workaround?

In the meantime I created the following base Mutation class to fix this issue, but it's hacky and I would love to not need this:

class Mutation(graphene.Mutation):
    @classmethod
    def Field(cls, **kwargs):
        return graphene.Field(
            cls._meta.output,
            args=cls._meta.arguments,
            resolver=cls._meta.resolver,
            **kwargs,
        )

    @staticmethod
    def mutate(*_, **__):
        raise NotImplementedError('Overwrite me!')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions