Skip to content

How to expose tagged union and alternative constructors in GraphQL #56

Answered by wyfo
thomascobb asked this question in Q&A
Discussion options

You must be logged in to vote

EDIT
An example of this use case is now presented in the documentation.




Actually, I've realized I've missed the whole point on alternative constructors … By the way, I've built my previous example on a symmetry between ScanSpec input and output, but you seemed to be only interested in the input part, so it's another misunderstanding on my side.

I will try to be more in line with your issue with this second response. For that, I will use the new release of apischema which brings the following elements : dataclass_input_wrapper and TaggedUnion. With both of them, things become a lot easier.

Here is your original example reworked with apischema:

import asyncio
from collections.abc import It…

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
1 reply
@thomascobb
Comment options

Comment options

You must be logged in to vote
8 replies
@wyfo
Comment options

@thomascobb
Comment options

@wyfo
Comment options

@thomascobb
Comment options

@thomascobb
Comment options

Answer selected by thomascobb
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