Use object type with name matching entity name by default
See original GitHub issueIs your feature request related to a problem?
When I added a second object type for ObjectType<User>
, named ActiveUser
, in addition to the existing User
object type, my existing queries returning IQueryable<User>
and Task<User?>
started returning the ActiveUser
object type.
(13.0.0-preview.52)
The solution you’d like
I assume that the engine finds two object types mapped to the User
entity – if so, it should select the object type with a name matching the entity type by default. f.e., if the entity type is User
and there is an object type with the same name (User
), then use that object type, otherwise …
… maybe it should also throw when there’s no matching object type and there is more than one object type mapped to the same entity? Just selecting an arbitrary object type from a list seems unexpected.
Entity type | Object type(s) | Use object type |
---|---|---|
User | User | User |
User | AppUser | AppUser (only one matching type) |
User | User, AppUser | User (name matches) |
User | PrivateUser, PublicUser | (exception) |
Product
Hot Chocolate
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:12 (5 by maintainers)
Top GitHub Comments
In GraphQL you can have unions an interfaces … like
If they have the same runtime time then there is no way for the GraphQL engine to pick a winner. This is done by calling
IsOfType
on the GraphQL type. So if there is a a property that can distinguish between the two states or something from the resolver context then this is possible again. But if you do not take care of things like this you will get impossible runtime behavior.📌