hasura / hasura/graphql-engine
Hasura jsonb fields _append/_prepend options in the insert mutations onConflict options
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
As per our project requirements we need options to **_append or _prepend** for jsonb fields
i checked it with update mutation, as per the below mutation it appends provided json data with existing record json data
```
update_test2(
_append:{additionalFields:{
CP:{
test1:"test1"
test2:"test2"
}
}}
where:{id:{_eq:9}}
){
affected_rows
returning{
id
additionalFields
}
}
```
same feature needed in the onConflict Section of the insert mutation
i.e. insert if record not found or on onConflict update the record or merge json record if append or prepend is selected
but as per the below mutation tried for insert, there is no options for _append or _prepend with update Column attribute
of onConflict
```
insert_test2(objects: [{id: 10, firstName: "Test4", additionalFields: {CS: {test2: "test2"}}}], on_conflict: {constraint: test2_pkey, update_columns: [additionalFields, firstName]}) {
affected_rows
returning {
firstName
id
additionalFields
}
}
```
### Describe the solution you'd like
Need the _append and _prepend options in insert mutations onConflict section
Contributor guide
Research direction
Start by tracing how insert mutations process the on_conflict update_columns option, then compare that path with the update mutation's existing _append and _prepend behavior described in the issue. Done means insert mutations accept _append and _prepend in the onConflict section and merge the JSONB record as requested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, postgresql
- Domain
- api, database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100