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
Unable to create array relationships from array of IDs #6845
Comments
Also running into the same issue. We have a bulk action that does many different things, and we would like to be able to return these as something like {
create: [18, 19, 20],
updated: [2, 7],
deleted: [1, 8, 9],
} There are ids of the items that changed. We'd like to be able to link those to 'post'. So that we can then get the data for all the created posts, updated posts, and deleted posts. The reason we cant return them in a single array such as |
@pandoratoolbox are you looking to create a one-to-many relationship? If so, what about adding a Lmk if that helps, or if I was off the mark in what you are trying to do. |
Any updates to this? Also would like to do similar attachment logic without extra tables. |
One media item can be used for many post items, one post item can use many media items |
Sounds like you are looking for a many-to-many relationship. You would want to create a pivot table to create the relationships between those two logical objects. |
Thanks for the intention to assist. I'm aware of using an intermediate table to establish this relationship but this is not how I'm intending to structure my data. Unfortunately it seems like Hasura does not fulfill my requirements currently. |
We have the same requirement here but it's on the output type of an action, we return a field called: Using a many-to-many table here doesn't work because the data is mutable, not persisted.. it's calculated at runtime. |
@rodrigoreis22 did you manage to solve that already? I am having exactly the some issue currently. Here is the relationship I am trying to create between the And this is the error I get when saving the relationship configuration: It seems that we are not allowed to make array relationships with arrays. Feels very illogical to me. Or am I just trying to approach this in a wrong way? |
Agree, we need this functionality too... any news on this? |
Hey folks, this is quite a different type of relationship. Something from For table relationships, a workaround is to create a view with each item in the list "unnested" and then creating relationships from this view. This is possible using the For Actions, a workaround is to return a list of objects for each ID at the top-level instead of returning a list of IDs. For example, taking the schema from the comment above:
Now you can create a relationship between |
(2.15 backport) console: refactored browse rows to refetch on every table name change GitOrigin-RevId: dff7dfe9dae2855631c3f55744c6d5ba72c07e61
(2.15 backport) console: refactored browse rows to refetch on every table name change GitOrigin-RevId: dff7dfe9dae2855631c3f55744c6d5ba72c07e61
(2.15 backport) console: refactored browse rows to refetch on every table name change GitOrigin-RevId: dff7dfe9dae2855631c3f55744c6d5ba72c07e61
(2.15 backport) console: refactored browse rows to refetch on every table name change GitOrigin-RevId: dff7dfe9dae2855631c3f55744c6d5ba72c07e61
We also just ran into this issue, any other ideas than creating a view? |
Looking for the same! EDIT: I figured out a workaround using computed fields. I created a function in SQL to return rows based on some logic, and then I created a computed field that points to this function. Works beautifully! |
@kokroo were you able to return relationship for the data of this computed field? Example: users.articles.category where articles are the rows returned from the computed field and category relates from article table to category table. Can you share your solution? |
@kokroo Also interested in your solution, cant wrap my head around what you're suggesting. cheers! |
@deathemperor No, this is not what I was doing. |
I have a table 'post' with the column 'media_ids'. I'm trying to create an array relationship to the 'media' table on it's 'id' column.
In Hasura, it seems that this is impossible although I see a similar issue from a while ago that was closed (#4464).
When querying after creating this relationship, an error is produced:
"error": { "exec_status": "FatalError", "hint": "No operator matches the given name and argument types. You might need to add explicit type casts.", "message": "operator does not exist: bigint[] = bigint", "status_code": "42883", "description": null },
Is there any solution to this? I've created a computed field to retrieve the media rows from the media_ids column, but now there is no way to do a nested insert for medias when inserting a post.
The text was updated successfully, but these errors were encountered: