hasura / hasura/graphql-engine

Nested Insert is not referencing id from parent

Open
#8,335 3 comments 0 reactions 0 assignees View on GitHub
k/bug
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information

Server Version:
CLI Version (for CLI related issue): 2.3.0

### Environment

Cloud - Heroku

### What is the expected behaviour?

The most nested object should still reference the id created from the parent.

### Keywords

- Nested Insert
- Insert an object along with its related objects through relationships

### What is the current behaviour?

Comment ID on the menu_item_restriction table is null.

### How to reproduce the issue?

1. Create tables similar to the screenshot
2. Insert a row that deep
3. column will be null

**Mutation Code**
```
export const CreateReview = gql`
mutation createReview (
$user_id: String!,
$place_id: Int!,
$rating: Int!,
$text: String!,
$comment_menu_items: comment_menu_item_arr_rel_insert_input,
$existing_menu_items: [menu_item_restriction_insert_input!]!
$sid: String
) {
insert_comment(
objects: {
rating: $rating,
user_id: $user_id,
text: $text,
comment_places: {data: {place_id: $place_id}},
comment_menu_items: $comment_menu_items,
sid: $sid,
}) {
returning {
id
}
},
insert_menu_item_restriction(objects: $existing_menu_items, on_conflict: {constraint: menu_item_restriction_pkey, update_columns: []}) {
returning {
menu_item_id
restriction_id
}
}
}
`;
```

### Screenshots or Screencast

![image](https://user-images.githubusercontent.com/36803168/158737235-86416c2d-7103-4d0f-8d57-e6173c3dc61a.png)
![image](https://user-images.githubusercontent.com/36803168/158737263-03e7c6bd-8058-4ec8-adf5-65134a8c8f8b.png)
![image](https://user-images.githubusercontent.com/36803168/158737293-4f8fa870-1f8c-4da6-843f-38856c666894.png)
![image](https://user-images.githubusercontent.com/36803168/158737317-ddc4b257-0fcd-4a72-b95c-a39b6882b8ab.png)

### Please provide any traces or logs that could help here.

### Any possible solutions?

### Can you identify the location in the source code where the problem exists?

### If the bug is confirmed, would you be willing to submit a PR?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.