-
-
Notifications
You must be signed in to change notification settings - Fork 554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to annotate union names with generics #3393
Comments
From what I can tell Union merging functionality such as with #711 would help. Does anyone know a workaround for this? Either via union merging or naming unions that contain a TypeVar? |
Made a quick-and-dirty patch that merges unions (at the |
@jacobmoshipco is this still valid? would you like to share the patch and see if we can fix the tests? 😊 |
@patrick91 I'll have to check if I still have it on my home computer; I'll get back to you on that. I think it caused some other issues with unions, though. |
(just switching accounts, I'm the same person as @jacobmoshipco)
859c859
< assert isinstance(graphql_type, GraphQLObjectType)
---
> assert isinstance(graphql_type, GraphQLObjectType | GraphQLUnionType)
861c861,864
< graphql_types.append(graphql_type)
---
> if isinstance(graphql_type, GraphQLUnionType):
> graphql_types += list(graphql_type.types)
> else:
> graphql_types.append(graphql_type) |
Tests: Tbh, I may have just forgotten to do a proper control test when testing it before. Unless you (@patrick91) think this is the wrong way to patch this, or that it would cause too much of a breaking change (it does rename some unions), I can go ahead and submit it as a PR. |
@enoua5 feel free to send the PR, I'll be happy to check the failures 😊 |
Describe the Bug
Strawberry's automatic type-naming for generics is ignoring annotated types on unions. Here are a few examples of what I've tried:
This causes the union type to be named
SomeTypeNotFoundError
:This causes
TypeError: SomeTypeObjectQueries fields cannot be resolved.
:Pulling the definition up has the same behaviour in both cases:
Specifying T in the union doesn't help
Splitting out the error union doesn't help, this also can't resolve fields:
System Information
Additional Context
It appears that the issue with the ones that raise an exception rather than simply having the wrong names have their problem stemming from not being able to from a union with an instance of
strawberry.union
Other potentially related issues
Upvote & Fund
The text was updated successfully, but these errors were encountered: