hasura / hasura/graphql-engine

Derive Upsert Commands

Open
#10,654 2 comments 0 reactions 0 assignees View on GitHub
k/enhancement
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Component
v3-engine
v3-ndc-postgres

### Is your proposal related to a problem?
v2 was supporting upserts via
```gql
mutation upsert_article {
insert_article (
objects: [
{
id: 1
title: "First Article",
content: "Updated article 1 content",
published_on: "2018-10-12"
}
],
on_conflict: {
constraint: article_title_key,
update_columns: [content]
}
) {
returning {
id
title
content
published_on
}
}
}
```
this has not been implemented in v3 so far.

### Describe the solution you'd like

derive a dedicated upsert command for all persisted models.

```gql
mutation upsert_article {
upsertArticle (
objects: [
{
id: 1
title: "First Article",
content: "Updated article 1 content",
published_on: "2018-10-12"
}
],
update_columns: [content]
}
) {
returning {
id
title
content
published_on
}
}
}
```

### Describe alternatives you've considered
Implement upsert commands via native operations.

Contributor guide

Open the contributing guide

Research direction

The issue names v3-engine and v3-ndc-postgres as the relevant components; start by comparing the existing v2 upsert mutation shape with the proposed v3 command. Done means deriving a dedicated upsert command for all persisted models with the requested update_columns and returning behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, postgres
Domain
api, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.