MichalLytek / MichalLytek/typegraphql-prisma

Overwriting types classes

Open
#115 2 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement priority:medium
Dominant language
TypeScript
Stars
918
Forks
130
PR merge metrics
No merged PRs in 30d

Description

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:

```ts
@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:

```ts
@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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start at the generator's emitted ArgsType and InputType artifacts, then trace how UserWhereUnique is selected; done means a validated replacement map can substitute generated object and input types without requiring an eject.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.