Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Assignees
Labels
questionFurther information is requested
@dcreekp

Description

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

      AltStyle によって変換されたページ (->オリジナル) /