question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Input is empty when using generated InputType

See original GitHub issue

Its a bit confusing to me but when using the generated input types im not able to get args from my graphql mutations. When using my own dto as described in the nestjs docs everything works as expected.

My resolver:

@Mutation(() => Business, { nullable: true })
  async createBusiness(
    @UserEntity() user: User,
    @Args('business') business: BusinessCreateInput,
  ) {
    console.log(business); // output: BusinessCreateInput {}
    return this.businessesService.create(business, user);
  }

My graphql mutation

mutation CreateBusiness{
  createBusiness(business: { name: "Test business" })
}

Any ideas why this happens when using the generated types?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
unlightcommented, Nov 16, 2021

What is your prisma schema, what version of nestjs and library are you using?

0reactions
unlightcommented, Nov 17, 2021

I think problem in whitelist = true. But it does not make sense to use whitelist = true with graphql, graphql is typed. I think you have some options here:

  1. Disable whitelist, and use ValidationPipe in specific methods (decorator @UsePipes) or parameters where its needed (@Param, @Body)
  2. You can try to attach @Allow decorator to all fields (from class-validator, see https://github.com/typestack/class-validator#whitelisting) to all generated graphql classes, see decorate config option - https://github.com/unlight/prisma-nestjs-graphql#decorate
Read more comments on GitHub >

github_iconTop Results From Across the Web

why input value is an empty string in this form? - Stack Overflow
I've created the form with the Id that i use for the variables and then after the submit i want to see the...
Read more >
<input type="time"> - HTML: HyperText Markup Language | MDN
<input> elements of type time create input fields designed to let the user easily enter a time (hours and minutes, and optionally seconds)....
Read more >
Empty Input Type for many to many relationship join tables #19
After excecute npx prisma generate we have some Input Types that's are empty, so, when i tried to run the nest app i...
Read more >
Checking if an input is empty with CSS - Zell Liew
You add a placeholder to your input · If the placeholder is hidden, it means the user typed something into the field ·...
Read more >
How to check if an input is empty with CSS - freeCodeCamp
You add a placeholder to your input · If the input is hidden, it means the user typed something into the field ·...
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