question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use object type with name matching entity name by default

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelstaibcommented, Sep 22, 2022

In GraphQL you can have unions an interfaces … like

union Users = User | ActiveUser

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.

0reactions
glen-84commented, Feb 1, 2023

📌

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity Class name is transformed into SQL table name with ...
Spring by default uses org.springframework.boot.orm.jpa.SpringNamingStrategy which splits camel case names with underscore.
Read more >
Chapter 2. Mapping Entities
The logical column name is defined by the Hibernate NamingStrategy implementation. The default JPA naming strategy uses the physical column name as the...
Read more >
Mapping Entity Class Names to SQL Table Names with JPA
In this short tutorial, we'll learn how to set SQL table names using JPA. We'll cover how JPA generates the default names and...
Read more >
Entity Types - EF Core
Entity types that use the same CLR type are known as shared-type entity types. These entity types need to be configured with a...
Read more >
Key annotations you need to know when working with JPA ...
By default, each entity class maps a database table with the same name in the default schema of your database. You can customize...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found