Skip to content
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

Mutation return type Promise<boolean> not inferreed as boolean #527

Closed
etudor opened this issue Jan 22, 2020 · 4 comments
Closed

Mutation return type Promise<boolean> not inferreed as boolean #527

etudor opened this issue Jan 22, 2020 · 4 comments
Labels
Community 👨‍👧 Something initiated by a community Duplicate 🔑 This issue or pull request already exists

Comments

@etudor
Copy link

etudor commented Jan 22, 2020

Describe the bug
Promise not resolved in mutation and this error is produced:

Error: You need to provide explicit type for default_1#deleteOrder !

To Reproduce

  @Authorized()
  @Mutation()
  async deleteOrder(
    @Arg('id', type => Int) id: number
  ): Promise<boolean> {
    const order = await OrderRepository.findById(id)
    order.deletedAt = new Date()

    await OrderRepository.save(order)

    return true
  }

Expected behavior
The output of the mutation should be inferred as boolean from the return type

Logs
If applicable, add some console logs to help explain your problem.
You can paste the errors with stack trace that were printed when the error occured.

Enviorment (please complete the following information):

  • OS: Docker on Windows
  • Node: v13.6.0
  • Package version: 0.17.5
  • TypeScript version: 3.7.3

Additional context
Add any other context about the problem here.

@MichalLytek
Copy link
Owner

Duplicate of #296 🔒

@MichalLytek MichalLytek added Community 👨‍👧 Something initiated by a community Duplicate 🔑 This issue or pull request already exists labels Jan 22, 2020
@etudor
Copy link
Author

etudor commented Jan 22, 2020

@MichalLytek I agree this is duplicate. But I find it to be a bug and not an enhancement. Because Boolean is not a type in type-graphql how can I manually set the return type in my case?

@Mutation(returns => Boolean) ### this won't work

Is there a quick solution for this until the enhancement is added?

@MichalLytek
Copy link
Owner

MichalLytek commented Jan 22, 2020

@etudor this has to work

  @Mutation(returns => Boolean)
  async deleteOrder(
    @Arg('id', type => Int) id: number
  ): Promise<boolean> {}

https://typegraphql.com/docs/scalars.html#aliases

@Jonasdoubleyou

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community 👨‍👧 Something initiated by a community Duplicate 🔑 This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants