[DecimalError] Invalid argument: undefined

See original GitHub issue

Hello, I’m facing an error with the decimal type, the prisma-graphql-type-decimal package has already been installed. Error trace

Error: [DecimalError] Invalid argument: undefined
    at new Decimal (/app/node_modules/@prisma/client/runtime/index.js:38450:13)
    at TransformOperationExecutor.transform (/app/node_modules/src/TransformOperationExecutor.ts:160:22)
    at TransformOperationExecutor.transform (/app/node_modules/src/TransformOperationExecutor.ts:333:33)
    at ClassTransformer.plainToInstance (/app/node_modules/src/ClassTransformer.ts:77:21)
    at Object.plainToClass (/app/node_modules/src/index.ts:71:27)
    at ValidationPipe.transform (/app/node_modules/@nestjs/common/pipes/validation.pipe.js:51:39)
    at /app/node_modules/@nestjs/core/pipes/pipes-consumer.js:16:33

Graphql mutation

mutation {
	createSalary(input: {
		currency: {
			connect: {
				id: 1
			}
		},
		from: 10.10,
		to: 15.15,
		schedule: MONTH,
		type: CONTRACT
	}) {
		id
	}
}

Part of scheme

generator client {
  provider = "prisma-client-js"
}

generator nestgraphql {
  provider = "prisma-nestjs-graphql"
  output   = "../src/@generated/prisma-nestjs-graphql"
}

datasource db {
  provider = "mysql"
  url          = env("DATABASE_URL")
}

model Salary {
  id         Int            @id @default(autoincrement()) @db.UnsignedInt
  type       SalaryType
  schedule   SalarySchedule
  currencyId Int            @db.UnsignedInt
  from       Decimal        @db.Decimal(15, 2)
  to         Decimal        @db.Decimal(15, 2)
  createdAt  DateTime       @default(now())
  updatedAt  DateTime       @updatedAt

  job Job[]
  currency Currency @relation(fields: [currencyId], references: [id], onDelete: Restrict)

  @@map("salaries")
}

Part of resolver

  @UseGuards(GqlAuthGuard)
  @Mutation(() => SalaryModel)
  async createSalary(
    @Args('input') input: SalaryCreateInput,
    @Info() info: GraphQLResolveInfo,
  ): Promise<Salary> {
    return this.salariesService.createSalary(input);
  }

Generated input

import { Field } from '@nestjs/graphql';
import { InputType } from '@nestjs/graphql';
import { SalaryType } from '../prisma/salary-type.enum';
import { SalarySchedule } from '../prisma/salary-schedule.enum';
import { Decimal } from '@prisma/client/runtime';
import { GraphQLDecimal } from 'prisma-graphql-type-decimal';
import { JobCreateNestedManyWithoutSalaryInput } from '../job/job-create-nested-many-without-salary.input';
import { CurrencyCreateNestedOneWithoutSalaryInput } from '../currency/currency-create-nested-one-without-salary.input';

@InputType()
export class SalaryCreateInput {

    @Field(() => SalaryType, {nullable:false})
    type!: keyof typeof SalaryType;

    @Field(() => SalarySchedule, {nullable:false})
    schedule!: keyof typeof SalarySchedule;

    @Field(() => GraphQLDecimal, {nullable:false})
    from!: Decimal;

    @Field(() => GraphQLDecimal, {nullable:false})
    to!: Decimal;

    @Field(() => Date, {nullable:true})
    createdAt?: Date | string;

    @Field(() => Date, {nullable:true})
    updatedAt?: Date | string;

    @Field(() => JobCreateNestedManyWithoutSalaryInput, {nullable:true})
    job?: JobCreateNestedManyWithoutSalaryInput;

    @Field(() => CurrencyCreateNestedOneWithoutSalaryInput, {nullable:false})
    currency!: CurrencyCreateNestedOneWithoutSalaryInput;
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
github-actions[bot]commented, Aug 29, 2022

🎉 This issue has been resolved in version 17.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

0reactions
solispauwelscommented, Aug 30, 2022

Thank you very much @unlight 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

[DecimalError] Invalid argument: undefined : r/terraluna - Reddit
When trying to move my USTC from terra station the above message shows up, did anyone have the same issue and solved it?...
Read more >
SOLVED - [DecimalError] Invalid argument: undefined Luna ...
[ DecimalError ]: Invalid argument : undefined This is the error that always shows up if you are trying to send your Luna...
Read more >
“Fee estimation failed” error: [DecimalError] Invalid argument
“Fee estimation failed” error: [DecimalError] Invalid argument: undefined. The same error appears when trying to swap USTC to LUNC.
Read more >
Vertical layout throws [DecimalError] Invalid argument ...
Rendered BarChart with empty chart and without errors. What is actually happening? Error: [DecimalError] Invalid argument: undefined at new ...
Read more >
Why am I getting this error "Invalid argument"? - Stack Overflow
On one page I have an error that only happens in IE 8 (possibly other versions of IE, but 8 is what I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found