Skip to content

Custom object return type & integration with graphql-scalars #390

Answered by valerii15298
valerii15298 asked this question in Q&A
Discussion options

You must be logged in to vote

For the input type I did find a solution to omit specific fields from input using TypeGraphQL.omit(input: true) in schema.prisma:

model someModel {
    prop1 String
    /// TypeGraphQL.omit(input: true)
    prop2 String
    @@id(fields: [prop1, prop2])
}

and then extend from generated input type and add custom fields with scalars from graphql-scalars package:

export class GeneratedInput {
  @TypeGraphQL.Field(_type => TypeGraphQL.Int, {
    nullable: false
  })
  prop1!: number;
}

custom:

import { URLResolver } from 'graphql-scalars';
export class CustomInput extends GeneratedInput {
  @TypeGraphQL.Field(_type => URLResolver, {
    nullable: false
  })
  prop2: URL;
}

But in cases for val…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@valerii15298
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by valerii15298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants