typegraphql-prisma icon indicating copy to clipboard operation
typegraphql-prisma copied to clipboard

Overwriting types classes

Open MichalLytek opened this issue 3 years ago • 2 comments

Right now we can easily add our own resolvers, own object types, args, inputs, etc.

However, we can't easily change and replace implementation of one object type or input type, like simplifying StringFilter or some UserWhereUnique input.

It would be possible to allow providing alternative implementation of such types, e.g. with proper validation:

@InputType()
class UserWhereUnique {
  // alternative body, fields and decorators used
}

const typeReplacementMap = {
  inputs: {
    UserWhereUnique
  },
};
export default typeReplacementMap;

So the generated artifacts would always use that provided type instead of the default generated ones:

@ArgsType()
export class UserFindOneArgs {
  @Field(() => typeReplacementMap.inputs.UserWhereUnique)
  name!: UserWhereUnique;
} 

This will make the generated artifacts harder to eject and use as standalone code but will reduce the need to do the eject at all.

MichalLytek avatar May 18 '21 09:05 MichalLytek

So the only option right now to actually change an input type would be to reimplement it completely and then use it in a custom resolver, right?

TimPietrusky avatar Jun 16 '21 21:06 TimPietrusky

Will this issue allow us to add a new field to an WhereInput? Today we need to implement the whole resolver, right?

melanke avatar Mar 30 '22 14:03 melanke