-
Notifications
You must be signed in to change notification settings - Fork 54
Missing custom types properties in suggested model types. #448
Comments
Hey @otrebu, these model types represent what your server will fetch from the backend(s) (DB, microservice, etc). A model type is something that a resolver implementation can return. The missing types you pointed out are relations. What would you ideally expect graphqlgen to generate for you? |
Hi @jasonkuhrt yes they are relations, but is it not normal to want to return them? Otherwise the strongly typing becomes a pain, as you return they prisma type which contains the relations as promises, which will be resolved anyway. So personally I would expect them to be part of the types returned by graphqlgen. |
What if a query field resolver fetches it’s scaler data from one backend data source but fetches the relations from another source. A model maps to/specifies what the return value of some resolver will be. Resolvers should do as little work as possible. If client doesn’t include comments in selection set then server should not wastefully fetch them—to encode this in model types means keeping type relations at best shallow (list of comment IDs, author I’d, etc. I need to make a diagram for this. |
we might want to merge this thread into #181 |
@jasonkuhrt is it not what the resolvers on a type, for a specific field are for? |
If you can, take a look at the generated resolver types:
|
Hi @jasonkuhrt, I think I must have been taking a wrong approach and got confused when using it with prisma. You probably don't need them... |
My
schema.graphql
contains:When I generate the types the suggested type for Post is:
I am not sure why comments and user are missing?
Steps to reproduce
Expected results
Actual results
Versions
The text was updated successfully, but these errors were encountered: