-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unknown decorator #6
Comments
https://www.google.com/search?q=Cannot+determine+a+GraphQL+output+type+for+the Did you run Actually this package is made for https://github.com/unlight/prisma-nestjs-graphql and in the end field should decorated like this:
|
I am also using "prisma-nestjs-graphql" and i played a lot yesterday. I also had the Field Definition the way you describe it here but the issue persists. I was able to help myself by rewriting a scalar following your approach but using this code as template: https://github.com/nestjs/nest/blob/master/sample/23-graphql-code-first/src/common/scalars/date.scalar.ts My scalar looks like this: import { CustomScalar, Scalar } from '@nestjs/graphql';
import { Decimal } from '@prisma/client/runtime/index.js';
import { Kind, ValueNode } from 'graphql';
@Scalar('Decimal')
export class DecimalScalar implements CustomScalar<string, any> {
description = 'An arbitrary-precision Decimal type';
parseValue(value) {
return new Decimal(value as Decimal.Value);
}
serialize = String;
parseLiteral(ast: ValueNode) {
if (ast.kind === Kind.INT || ast.kind === Kind.FLOAT || ast.kind === Kind.STRING) {
return new Decimal(ast.value);
}
// eslint-disable-next-line unicorn/no-null
return null;
}
} With:
In schema.prisma. And i had to add it to the submodule (also like in the example code repo mentioned above). Adding it to the app.module "GraphQLModule.forRootAsync" did not work, too. Maybe the documentation is outdated. I also use the BigInt scalar from https://the-guild.dev/graphql/scalars, those are working out of the box. I dont know what they are doing differentely but for BigInt i only add
No need to add something inside the submodule or app module at all.. |
Hi, This is what i did in prisma: /// @HideField({ input: true, output: false })
wage Decimal? @db.Decimal(10, 2) This is the generated output from "prisma-nestjs-graphql" after running prisma generate import { GraphQLDecimal } from 'prisma-graphql-type-decimal';
import { Decimal } from '@prisma/client/runtime/library';
@Field(() => GraphQLDecimal, {nullable:true})
wage!: Decimal | null; This is the error: 'Error: Cannot determine a GraphQL output type for the "wage". Make sure your class is decorated with an appropriate decorator.\n' + Did i miss something? |
Hi,
i tried to use this scalar but it keeps failing with:
This is what i did in the gql config:
And here is the model:
Maybe i missed something but i am stuck right now.
Any advice?
The text was updated successfully, but these errors were encountered: