最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

graphql - Schema must contain uniquely named types but contains multiple types named "activityInterface" - Sta

programmeradmin3浏览0评论
  • NEST js, TypeOrm, Graphql I don't have Idea why I'm having this error, doesn't exit any other type with the same name I need this form because. I'm using jsonb, for the data, this is the reason I have nested objects.

ERROR:
Waiting for the debugger to disconnect... /Users/angelzapata/Desktop/Work/compass-backend/node_modules/graphql/type/schema.js:219 throw new Error( ^

Error: Schema must contain uniquely named types but contains multiple types named "activityInterface".

//#region Activity
@InterfaceType("activityInterface")
export abstract class ActivityInterface {
    @Field(() => String)
    name: string;

    @Field(() => String, { nullable: true })
    description?: string;

    @Field(() => String)
    type: ActivityType;

    @Field(() => String)
    picture_rule: ActivityRule;

    // @Field(() => File, { nullable: true })
    // picture?: File;

    @Field()
    comment_rule: ActivityRule;

    @Field(() => String, { nullable: true })
    comment?: string;

    // @Field(() => ActivityForm)
    // input_form: ActivityForm;
}

// Output
@ObjectType("activityOutput", { implements: ActivityInterface })
export class ActivityOutput implements ActivityInterface {
    @Field(() => String)
    name: string;

    @Field(() => String, { nullable: true })
    description?: string;

    @Field(() => String)
    type: ActivityType;

    @Field(() => String)
    picture_rule: ActivityRule;

    // @Field(() => File, { nullable: true })
    // picture?: File;

    @Field()
    comment_rule: ActivityRule;

    @Field(() => String, { nullable: true })
    comment?: string;

    // @Field(() => ActivityFormOutput)
    // input_form: ActivityFormOutput;
}

// Input
@InputType("activityInput")
export class ActivityInput implements ActivityInterface {
    @IsNotEmpty()
    @IsString()
    @Field(() => String)
    name: string;

    @IsOptional()
    @IsString()
    @Field(() => String, { nullable: true })
    description?: string;

    @IsNotEmpty()
    @IsEnum(ActivityType)
    @Field(() => String)
    type: ActivityType;

    @IsNotEmpty()
    @IsEnum(ActivityRule)
    @Field(() => String)
    picture_rule: ActivityRule;

    // @IsOptional()
    // @Field(() => File, { nullable: true })
    // picture?: File;

    @IsNotEmpty()
    @IsEnum(ActivityRule)
    @Field()
    comment_rule: ActivityRule;

    @IsOptional()
    @IsString()
    @Field({ nullable: true })
    comment?: string;

    // @ValidateNested()
    // @Field(() => ActivityFormInput)
    // input_form: ActivityFormInput;
}
//#endregion Activity

//#region ServiceTemplateSection
@InterfaceType("serviceTemplateSectionInterface")
export abstract class ServiceTemplateSection {
    @Field(() => String)
    name: string;

    @Field(() => [ActivityInterface])
    activities: ActivityInterface[];
}

// Output
@ObjectType("serviceTemplateSectionOutput", {
    implements: ServiceTemplateSection,
})
export class ServiceTemplateSectionOutput implements ServiceTemplateSection {
    @Field(() => String)
    name: string;

    @Field(() => [ActivityOutput])
    activities: ActivityOutput[];
}

// Input
@InputType("serviceTemplateSectionInput")
export class ServiceTemplateSectionInput {
    @IsNotEmpty()
    @IsString()
    @Field(() => String)
    name: string;

    // @ValidateNested({ each: true })
    @Field(() => [ActivityInput])
    activities: ActivityInput[];
}
//#endregion ServiceTemplateSection

I don't find any solution on internet, have anyone had the same problem? how did you resolve that?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论