Comments (4)
dataloaders dont work on em.find
at all, they are only for reference and collection loading.
not sure how that could be combined with nest, any ideas @darkbasic?
edit: I guess something like this should work:
@ResolveField(() => User)
public async author(@Parent() book: Book) {
return book.author.load();
}
note that you need to use the Reference
wrapper for your relation:
@ManyToOne(() => User, { ref: true })
public author: Ref<User> // Ref, not Rel
edit 2: moving back to the main repo, as the dataloader docs would indeed deserve more details about this
from mikro-orm.
Btw there is apparently one alternative if you dont want to use the Ref
wrapper - you can create it via wrap
helper dynamically and return that from your resolver:
@ResolveField(() => User)
public async author(@Parent() book: Book) {
return wrap(book.author).toReference().load();
}
(at least that's what one user recently said worked for them)
I would still rather suggest using it - type safe relations (Loaded
type) depend on this too.
from mikro-orm.
Thank you for the quick response, I've tried here and just works!
from mikro-orm.
hope this makes it clearer, PR welcome if you see more room for improvements
from mikro-orm.
Related Issues (20)
- docs: The docs list EntityManager.find() and findAll() fields as "Fields: string = ALL" or "Fields: string = *" but its actually an array HOT 1
- Security Concern: Use of Weak Hashing Algorithm in node_modules/pg/lib/crypto/utils-webcrypto.js
- Entity Generator: Relationships generated as OneToOne when ManyToOne relationship has a unique index HOT 1
- PostgreSqlPlatform and DateTimeType do not correctly handle the timestamp and timestamptz types HOT 3
- Virtual entity findByCursor not working
- UpsertMany does not update the table with the new data.
- [BUG]: Duplicate joins are being generated in SQL queries when populating relationships using
- Single table inheritence no longer supports different custom types for a common property under different classes HOT 2
- "json" column typed fields are not being parsed in postgres platform
- QB not populate relation
- docs: Improvements in Decorators Documentation
- docs: Turso connection configuration HOT 1
- support pglite as datasource
- Always occur errors say `ERROR [ExceptionHandler] no pg_hba.conf entry for host` HOT 2
- Add the ability to orderBy pivotTable properties in the basic repository methods.
- docs: deindex old versions of documentation
- SQL Error occurs when trying to create DESC Index in PostgreSQL HOT 2
- Incorrectly passed QueryParams to SQL query HOT 2
- [Regression] Populating an embedded relationship to an entity with a lazy property does not work properly
- Serializing using toObject ignores populated fields
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mikro-orm.