typegraphql

Best way to handle one-to-many with type-graphql typeorm and dataloader

我怕爱的太早我们不能终老 提交于 2021-02-19 01:38:08
问题 I'm trying to figure out the best way to handle a one-to-many relationship using type-graphql and typeorm with a postgresql db (using apollo server with express). I have a user table which has a one-to-many relation with a courses table. The way I am currently handling this is to use the @RelationId field to create a column of userCourseIds and then using @FieldResolver with dataloader to batch fetch the courses that belong to that user(s). My issue is that with the @RelationId field, a

How to implement GraphQL Scalar for MongoDB sort property found in collection.find() function of MongoDB's?

强颜欢笑 提交于 2021-01-29 13:40:13
问题 I'm trying to create an argument type using type-graphql to accept arguments through the GraphQL query. The sort I'm talking about is a property of the options found on MongoDB's native NodeJS driver documentation. @ArgsType() export class FindAllArgs implements FindOneOptions { @Field(type => Int, { defaultValue: 0, description: 'Sets the limit of documents returned in the query.' }) @Min(0) limit?: number; // This is where the custom sort would go about. @Field(type => SortScalar) sort?:

Cannot determine GraphQL input type for argument named

怎甘沉沦 提交于 2021-01-29 07:06:59
问题 I have two relationed models: 1.- RoleEntity import { Column, Entity, BaseEntity, OneToMany, PrimaryColumn } from "typeorm"; import { Field, ObjectType } from "type-graphql"; import { UserEntity } from "./user.entity"; @ObjectType() @Entity({ name: "tb_roles" }) export class RoleEntity extends BaseEntity { @Field() @PrimaryColumn({ name: "id", type: "character varying", length: 5 }) id!: string; @Field() @Column({ name: "description", type: "character varying", nullable: true }) description!:

What is the proper way to unit test Service with NestJS/Elastic

我与影子孤独终老i 提交于 2020-08-02 07:57:37
问题 Im trying to unit test a Service that uses elastic search. I want to make sure I am using the right techniques. I am new user to many areas of this problem, so most of my attempts have been from reading other problems similar to this and trying out the ones that make sense in my use case. I believe I am missing a field within the createTestingModule. Also sometimes I see providers: [Service] and others components: [Service] . const module: TestingModule = await Test.createTestingModule({