[RFC] Import Generated Types to Actions #9273
Replies: 4 comments 2 replies
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
While I agree that having an easy way to clone types will ease the current problem a bit I don't think it really solves it. In an ideal scenario I'd see the type used in the table being the same as the action's one. That way we avoid: type drifting, duplication, and potential manual syncing. If automatic joins with relations isn't possible/too complex, could a stop gap be that Hasura leverages the same mechanism used in remote schemas to connect results back to the db at least? |
Beta Was this translation helpful? Give feedback.
-
@dariocravero - thanks for your comment. Would like to know the scenario when your database type changes, would you like your Action definitions to be in sync with that type change or would you expect to change them manually. And will such changes in your database schema would cause any disruption in clients who are using the dependent actions. We would like to update you that reusing enums in Actions is on the roadmap. Does your use-case involve enums? If not what kind of types are you looking to reuse? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
This GitHub issue has ~100 impressions and a lot of comments.
There could be types that users want to use on Action definitions from the table schema, for example if there is a table called “authors” and if the user wants to use the type “authors” in an Action then the user needs to type this manually in the Action creation form. When there are many such types, it takes some effort and manual work to fill up the form. It also requires some learning about GraphQL types.
We suggested a possible solution that will be explained later in this document, which received some positive feedback.
Problem
Redefining generated types in Actions is time consuming especially when there are many type definitions. Right now if a user wants to use a generated type from Hasura, they need to define it manually from the console - which is time consuming.
Solution
While there are multiple solutions to think about, with this RFC we will discuss more of a solution that helps users to import types directly from a table shape into the Action definition.
The solution mentioned here will be available as beta from v2.17 and the purpose of this RFC is to discuss more on the enhancement plans, use cases etc. to fine tune it before GA release.
As we already have the shape of the table in the introspection response, Hasura Console can use this to generate these types so the users can simply use it on the Action definition.
The UX would be as simple as follows,
From Table
would open up a new modal window as shown belowPossible Enhancements
Added separate comments (provided links to it on the following list) to each of these enhancements, so that we can identify the most asked enhancements and prioritise further.
type
->input
. This might be useful when users import a lot of tables at the same time. (link)Beta Was this translation helpful? Give feedback.
All reactions