ChilliCream / ChilliCream/graphql-platform

Use object type with name matching entity name by default

Open
#5,399 10 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ hot chocolate Area: Type System
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

Is 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with ObjectType and a second ActiveUser object type, then inspect the code paths that map entity types to object types for IQueryable and Task<User?> queries. Verify the documented cases: prefer a same-name object type, use the sole mapped type otherwise, and define the behavior when multiple differently named types remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.