'NestJS getting relationship info to graphql
I'm trying to access a property from the many-to-many relationship model. But NestJS's GraphQL implementation won't let me. I've tried already IntersectionType, creating a custom type, ...
But everything gives me:
throw new TypeError();
^
TypeError:
at Reflect.getMetadata...
Example:
export class Model1{
@Field(() => ID)
@PrimaryKey
@Column
id: string;
@BelongsToMany(() => Model2, () => Relation )
others: (Game & { Relation : Relation })[];
}
export class Model2{
@Field(() => ID)
@PrimaryKey
@Column
id: string;
@BelongsToMany(() => Model1, () => Relation )
others: (Game & { Relation : Relation })[];
}
export class Relation {
@ForeignKey(() => Model1)
@Field({ nullable: true })
@Column
model1Id: string;
@ForeignKey(() => Model2)
@Field({ nullable: true })
@Column
model2Id: string;
@Column
some_property: string
}
How would you setup your graphql properties so I can access the some_property from the relation object?
I can access it in code. But I can't seem to setup the graphql attributes so I can query them.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
