prisma-nestjs-graphql icon indicating copy to clipboard operation
prisma-nestjs-graphql copied to clipboard

[Question] rename field

Open Namir7 opened this issue 3 years ago • 3 comments

Hi,

thnx for great work

I have one question: Is there any way to rename field inside gql type?

schema.prisma

model User { id: String @id

/// @Field({ name "another_name" }) field: String }

@generated/index.ts

@ObjectType({}) export class User { @Field(() => ID, { nullable:false }) id!: string;

@Field(() => String, { nullable:false, name: "another_name" })
field: string;

}

Namir7 avatar Dec 16 '22 21:12 Namir7

You want different name in graphql schema? You can expose custom name by using ResolveField https://docs.nestjs.com/graphql/resolvers

If you want different names in tables, see @@map Prisma schema API https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#map-1

unlight avatar Dec 17 '22 17:12 unlight

Actually, I want to change name in GQL schema by "name" option in "@Field" decorator @Field(() => String, { name: "antoher_name" })

Namir7 avatar Dec 18 '22 06:12 Namir7

@Field decorator is a part of nestjs/graphql module.

unlight avatar Dec 18 '22 10:12 unlight