MichalLytek / type-graphql

Create GraphQL schema and resolvers with TypeScript, using classes and decorators!

Home Page:https://typegraphql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested objects in queries

aaaltonen opened this issue · comments

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.

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