Replies: 1 comment
-
|
Yes, Ariadne fully supports GraphQL Unions. Use the from ariadne import UnionType
search_result = UnionType("SearchResult")
@search_result.type_resolver
def resolve_search_result_type(obj, *_):
if "username" in obj:
return "User"
if "title" in obj:
return "Post"
return None
schema = make_executable_schema(type_defs, search_result)The type resolver examines the object and returns the concrete type name as a string. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When I run the code generator the output doesn't seem to work because GraphQL unions are treated like standard types. Are GraphQL unions supported?
Beta Was this translation helpful? Give feedback.
All reactions