Skip to content

Union response type not working #850

Answered by murtukov
WouterCypers asked this question in Q&A
Discussion options

You must be logged in to vote

@WouterCypers you should use union types exactly like interfaces. You can check the documentation for interfaces for more details.

In your case you should define for your abstract type (ResetPasswordResponse) a type resolver (resolveType):

ResetPasswordResponse:
  type: union
  config:
    types: [ResetPasswordSuccessfulResponse, ResetPasswordFailedResponse]
    description: 'Reset password succeeded or failed.'
    resolveType: "@=mutation('map_response_type', value, typeResolver)"

And modify your ResetPasswordMutation class:

use GraphQL\Type\Definition\ObjectType;
use Overblog\GraphQLBundle\Resolver\TypeResolver;
use Overblog\GraphQLBundle\Resolver\UnresolvableException;

class ResetPas…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@WouterCypers
Comment options

@murtukov
Comment options

Answer selected by murtukov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #849 on May 14, 2021 09:32.