Skip to content

Able to return None when you are not supposed to?? #229

Open
@dcreekp

Description

@dcreekp

Reporting issues with GraphQL-core 3

I came across an issue that may be due to Graphene but the problem surfaces here.

I was writing a mutation which would raise an Error or return:

{"data": {"someMutationThatReturnsNone": None}

instead of something like:

{"data": {"someMutationThatWillAlwaysBeTrueIfNoErrorRaised": {"success": True}}}

I was happy that this worked:

class SomeMutationThatReturnsNone(graphene.Mutation):

    class Arguments:
        ...

    Output = CustomNullTypeScalar

    def mutate(self, info: graphene.ResolveInfo, **kwargs: Any) -> None:
        ...
        return None

until I realised that this would also work:

class SomeMutationThatReturnsNone(graphene.Mutation):

    class Arguments:
        ...

    Output = graphene.Date(required=True)

    def mutate(self, info: graphene.ResolveInfo, **kwargs: Any) -> None:
        ...
        return None

currently, because the line of code linked above is before the check if is_leaf_type(return_type), so long as Output = someScalarOrEnumType the mutation will return {"data": {"someMutationThatReturnsNone": None}.
Which I don't think is right.

Would appreciate your thoughts.

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions