Hi, this seems reasonable. If I read it correctly it seems we are using the resolver essentially as a "service" to retrieve ( from the repository ) the data, structure it and return it.
My first question would be what happens when your domain model does not exactly match you data tables ( as it shouldn't since they are for two wildly different things )? Is there any support in typeorm for the actual M part? The mapping of relational data structure to object data structure?
Another question is, does this setup handle the n+1 query problem inherent in gql? I.e. user has a collection of dogs. Each do has a collection of fleas. I need the names of all the fleas. This creates a great number of DB queries. N+1 queries in fact :).
If you know of someone docs or articles that address these questions that would be great. Or if you want to write a post on it even better.
Thanks
Raif
I'm Software Architect and Full Stack Software Developer, Open Source enthusiast, TS/JS enthusiast, passionate about NestJS, Fastify, Angular and React/Next.js
For the first question, if I understand correctly, you are looking for documentation on how to create relationships between tables with Typeorm, right? you can see in the official documentation, see here: typeorm.io/relations
I personally don't have a favorite ORM, in this tutorial I used TypeORM because I saw that it is the most used with NestJS and so I used that :-), but you can use whatever you prefer :-) Â
While for the second question regarding the GraphQL 1+n problem in this example is not implemented, I was planning to make a separate post or update this one, just due to lack of time I could not do it :-)
To get an example you can take a look at this link: wanago.io/2021/02/08/api-nestjs-n-..., you can find many more examples about NestJS ( relations, etc..)
i hope i was helpful
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi, this seems reasonable. If I read it correctly it seems we are using the resolver essentially as a "service" to retrieve ( from the repository ) the data, structure it and return it.
My first question would be what happens when your domain model does not exactly match you data tables ( as it shouldn't since they are for two wildly different things )? Is there any support in typeorm for the actual M part? The mapping of relational data structure to object data structure?
Another question is, does this setup handle the n+1 query problem inherent in gql? I.e. user has a collection of dogs. Each do has a collection of fleas. I need the names of all the fleas. This creates a great number of DB queries. N+1 queries in fact :).
If you know of someone docs or articles that address these questions that would be great. Or if you want to write a post on it even better.
Thanks
Raif
Hi,
For the first question, if I understand correctly, you are looking for documentation on how to create relationships between tables with Typeorm, right? you can see in the official documentation, see here: typeorm.io/relations
I personally don't have a favorite ORM, in this tutorial I used TypeORM because I saw that it is the most used with NestJS and so I used that :-), but you can use whatever you prefer :-) Â
While for the second question regarding the GraphQL 1+n problem in this example is not implemented, I was planning to make a separate post or update this one, just due to lack of time I could not do it :-)
To get an example you can take a look at this link: wanago.io/2021/02/08/api-nestjs-n-..., you can find many more examples about NestJS ( relations, etc..)
i hope i was helpful