Got a bit of noob question: I'm running mutations ...
# orm-help
r
Got a bit of noob question: I'm running mutations that add nested data via
{ create: { ... }
or
{ connect: { ... } }
and I can see the records in my postgres database (in the tables starting with _), but when I query across data relations, it never comes back - nothing more complicated than this example: https://www.prisma.io/docs/prisma-graphql-api/reference/queries-qwe1/#querying-data-across-relations
m
No nothing needs to be enabled specifically. Can you share an example?
r
I'll get some gists together - one sec
This is (sort of/mostly) the source I'm using https://gist.github.com/remy/f7c253cf48b42937db684d33722f5bb0
The mutation on createUser works fine, and the resolver runs, and when I check the raw postgres database, I can see the records for
user
and
accountSubscription
and
_AccountSubscriptionToUser
but when I try to query it out, via the playground, if I ask for the
accountSubscription
, it just gives me that error (that it's null) - like prisma hasn't resolved the nested data.
Manually query gets me the data too, but I'm not sure how Prisma does this internally:
select A.state from backend$dev."User" as U, backend$dev."_AccountSubscriptionToUser" as AU, backend$dev."AccountSubscription" as A where AU."B"=U.id and U.id='cjr6jbaro00060718tpo1gp86' and AU."A"=A.id;
That query returns the joined row.
To add to this, I have a custom resolver for the
query { user }
request:
module.exports = (parent, { id }, ctx) => ctx.prisma.user({ id });
h
Are you resolving the accountSubscription on User?
r
I'm having to in code, yes. If I don't include a resolver for the
accountSubscription
then it Prisma doesn't do it for me.
h
Yes right now, you have to resolve in the fields. We are going to solve this problem soon with updates to the client
r
sounds good, cheers.