MichalLytek / type-graphql

Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
https://typegraphql.com
MIT License
7.98k stars 674 forks source link

Nested objects in queries #1615

Closed aaaltonen closed 5 months ago

aaaltonen commented 5 months ago

I have query defined on my resolver like this:

@Query(() => User) user(@Arg("id") id: number) { return User.findOne({ where: { id, }, relations: { reservations: { user: true, }, announcements: true, role: true, uploadFiles: { roles: true, }, }, }); }

And when im querying my api like this: query User($userId: Float!) { user(id: $userId) { id firstName lastName email phone role { name } uploadFiles { created_at displayName roles { name } }

I get error: Cannot return null for non-nullable field Role.name. Im not sure what i'm doing wrong because that object contains "role" objects with data like "name" etc. I would really appreciate some assistance.

MichalLytek commented 5 months ago

You've already asked in gh discussion. This is not a bug report and gh issues are not a helpdesk 🔒