paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
679 stars 55 forks source link

`__typename` not returned in select #299

Closed baptistemarchand closed 11 months ago

baptistemarchand commented 11 months ago

Hi,

I have a query that looks like this :

user() {
    id
    firstname
    __typename
}

But when I do new PrismaSelect(info).value in my resolver, the result is { select: { id: true, firstname: true } }. Why is __typename not returned?

Thank you in advance for your help.

AhmedElywa commented 11 months ago

Hi

because the __typename is not in your prisma model and it's added by default from the graphql server

baptistemarchand commented 11 months ago

Thank you for your very quick answer! In my case I had added a __typename field to all models with the help of a prisma client extension (don't ask..), that's why I was expecting the field to show up. But anyway, I solved my issue. Sorry for the noise.

Not related to __typename, but in case it can help someone stumbling on this issue : if you have a typo in your schema.prisma, the field won't be returned in the select and you won't get any errors.