MichalLytek / MichalLytek/typegraphql-prisma
Adding custom scalars
- Dominant language
- TypeScript
- Stars
- 918
- Forks
- 130
- PR merge metrics
- No merged PRs in 30d
Description
It would be useful if there would be a way to map certain primitive field scalars from certain types of the prisma schema to custom graphql scalars for example with [graphql-scalars](https://github.com/Urigo/graphql-scalars) to have an even stricter type system which also reduces the need for [class-validator](https://github.com/typestack/class-validator) since the validation takes place directly at the resolver level. It would be really nice to have this feature to have more control over the schema generation.
### Example:
type definition of `Person` in `prisma.schema` with the primitive type `String`:
``` prisma
model Person {
email String
}
```
type definition of `Person` in `schema.graphql` with a custom scalar `EmailAddrress`:
``` gql
type Person {
email: EmailAddress
}
```
generated type definition of `Person` as a typegraphql object type with custom scalar resolver:
``` ts
import { EmailAddressResolver } from 'graphql-scalars';
@ObjectType()
export class Person {
@Field(() => EmailAddressResolver)
email!: string;
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.