Last active
April 28, 2021 10:14
-
-
Save theo-m/9dd94171ef61501885e5a6f0597d68c2 to your computer and use it in GitHub Desktop.
bug-description
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Nest] 85816 - 04/28/2021, 11:57:39 AM [InstanceLoader] NestjsQueryGraphQLModule dependencies initialized +0ms | |
[Nest] 85816 - 04/28/2021, 11:57:39 AM [InstanceLoader] NestjsQueryGraphQLModule dependencies initialized +0ms | |
[Nest] 85816 - 04/28/2021, 11:57:39 AM [RoutesResolver] AppController {}: +6ms | |
[Nest] 85816 - 04/28/2021, 11:57:39 AM [RouterExplorer] Mapped {, GET} route +2ms | |
(node:85816) UnhandledPromiseRejectionWarning: Error: Cannot determine a GraphQL output type for the "findOwner". Make sure your class is decorated with an appropriate decorator. | |
at OutputTypeFactory.create (/Users/theo/Code/monorepo/back/node_modules/@nestjs/graphql/dist/schema-builder/factories/output-type.factory.js:19:23) | |
at /Users/theo/Code/monorepo/back/node_modules/@nestjs/graphql/dist/schema-builder/factories/object-type-definition.factory.js:77:53 | |
at Array.forEach (<anonymous>) | |
at /Users/theo/Code/monorepo/back/node_modules/@nestjs/graphql/dist/schema-builder/factories/object-type-definition.factory.js:76:24 | |
at resolveThunk (/Users/theo/Code/monorepo/back/node_modules/graphql/type/definition.js:480:40) | |
at defineFieldMap (/Users/theo/Code/monorepo/back/node_modules/graphql/type/definition.js:692:18) | |
at GraphQLObjectType.getFields (/Users/theo/Code/monorepo/back/node_modules/graphql/type/definition.js:633:27) | |
at collectReferencedTypes (/Users/theo/Code/monorepo/back/node_modules/graphql/type/schema.js:366:81) | |
at new GraphQLSchema (/Users/theo/Code/monorepo/back/node_modules/graphql/type/schema.js:148:9) | |
at GraphQLSchemaFactory.<anonymous> (/Users/theo/Code/monorepo/back/node_modules/@nestjs/graphql/dist/schema-builder/graphql-schema.factory.js:40:28) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm'; | |
import { User } from '../user'; | |
import { UuidEntity } from '../uuid.entity'; | |
@Entity('home') | |
export class Home extends UuidEntity { | |
@Column() | |
address: string; | |
@Column({ name: 'owner_id', nullable: true }) | |
ownerId: number | null; | |
@ManyToOne(() => User, (user) => user.homes) | |
@JoinColumn({ name: 'owner_id' }) | |
owner: Promise<User | null>; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
FilterableField, | |
FilterableRelation, | |
Relation, | |
} from '@nestjs-query/query-graphql'; | |
import { | |
Field, | |
GraphQLISODateTime, | |
ID, | |
InputType, | |
ObjectType, | |
} from '@nestjs/graphql'; | |
import { GQLUser } from '../user'; | |
@ObjectType('Home') | |
@Relation('owner', () => GQLUser, { nullable: true }) | |
export class GQLHome { | |
@FilterableField(() => String) | |
@Field(() => String) | |
uuid: string; | |
@Field() | |
address: string; | |
@Field(() => GraphQLISODateTime) | |
createdAt: Date; | |
@Field(() => ID) | |
ownerUuid: string; | |
} | |
// INPUT TYPES | |
@InputType('HomeInput') | |
export class GQLHomeInput { | |
@Field() | |
address!: string; | |
@Field(() => ID) | |
ownerUuid: string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Module } from '@nestjs/common'; | |
import { TypeOrmModule } from '@nestjs/typeorm'; | |
import { NestjsQueryTypeOrmModule } from '@nestjs-query/query-typeorm'; | |
import { NestjsQueryGraphQLModule } from '@nestjs-query/query-graphql'; | |
import { HomeService } from './home.service'; | |
import { HomeResolver } from './home.resolver'; | |
import { HomeRepository } from './home.repository'; | |
import { Home } from './home.entity'; | |
import { GQLHome, GQLHomeInput } from './home.model'; | |
@Module({ | |
imports: [ | |
NestjsQueryGraphQLModule.forFeature({ | |
imports: [NestjsQueryTypeOrmModule.forFeature([Home])], | |
resolvers: [ | |
{ | |
DTOClass: GQLHome, | |
EntityClass: Home, | |
CreateDTOClass: GQLHomeInput, | |
UpdateDTOClass: GQLHomeInput, | |
}, | |
], | |
}), | |
TypeOrmModule.forFeature([HomeRepository]), | |
], | |
providers: [ | |
HomeService, | |
// HomeResolver | |
], | |
}) | |
export class HomeModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Field, | |
InputType, | |
ObjectType, | |
registerEnumType, | |
} from '@nestjs/graphql'; | |
import { FilterableField, UnPagedRelation } from '@nestjs-query/query-graphql'; | |
import { UserRoleEnum } from './user.entity'; | |
import { GQLHome } from '../home/home.model'; | |
registerEnumType(UserRoleEnum, { name: 'UserRole' }); | |
@ObjectType('User') | |
@UnPagedRelation('homes', () => GQLHome) | |
export class GQLUser { | |
@FilterableField(() => String) | |
@Field(() => String) | |
uuid: string; | |
@Field() | |
name: string; | |
@Field() | |
email: string; | |
@Field(() => UserRoleEnum) | |
role: UserRoleEnum; | |
} | |
// INPUT TYPES | |
@InputType('UserInput') | |
export class GQLUserInput { | |
@Field({ nullable: false }) | |
email!: string; | |
@Field({ nullable: false }) | |
name!: string; | |
@Field(() => UserRoleEnum, { nullable: false }) | |
role!: UserRoleEnum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment