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.

reuse enum types in actions

See original GitHub issue

Current behavior

I have an enum table userGender with a correctly set foreign key on table user and column gender. The generated insert_user_one then expects a custom type userGender_enum, that’s kinda cool and works well with a codegen.

I have also a mutation action signUp that accepts the gender of the user on the input and calls (among others) a generated mutation insert_user_one. When I want to specify generated userGender_enum for the input it won’t allow it.

validation for the given custom types failed because the type “userGender_enum” for field “gender” in input object type “SignUpInput” does not exist

Expected behavior

I know that in practice, this doesn’t matter that much because the underlying foreign key will still check the input. It’s definitely nicer for GraphiQL and others to make writing queries for actions easier if they are correctly type-checked.

Unfortunately, it’s a problem with the generated typescript code. It causes inconsistency in data type String on input (from SignUpInput) and data type for inserting users which is based on the enum.

I expect that enum table type can be used in the custom input type for an action.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:37
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
amal-chandrancommented, Dec 9, 2021

Up If we can use enum tables as the source of truth for actions then we can reduce a lot of manual code. Currently, we are using enum tables as a source of truth in both frontend and backend with help of graphql-codegen

4reactions
pakokrewcommented, Feb 13, 2021

Up

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reusing enum values in separate enum types - c++
Is there a way to reuse the same enum value in separate types? I'd like to be able to something like the following:...
Read more >
How to extend enums in TypeScript - LogRocket Blog
The short answer is no, you can't extend enums because TypeScript offers no language feature to extend them. However, there are workarounds you ......
Read more >
Postgres: Enum type fields | Hasura GraphQL Docs
Enum type fields are restricted to a fixed set of allowed values. Enums in a database​. In a relational database such as Postgres,...
Read more >
Reusable enums in Absinth : r/elixir - Reddit
Have you ever had a problem referencing existing enum functions in Absinth? Something like: defmodule MyEnums do @currencies [ :eur, :pln, ...
Read more >
Enums - Swagger
You can use the enum keyword to specify possible values of a request parameter or a model ... Reusable enum definitions are supported...
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