typegraphql-prisma
typegraphql-prisma copied to clipboard
Overwriting types classes
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.
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?
Will this issue allow us to add a new field to an WhereInput? Today we need to implement the whole resolver, right?