一覧へ戻る
cdaringe/postgraphile-upsert(新しいタブで開きます)
主要言語: TypeScript
add postgres upsert mutations to postgraphile :elephant:
- star 数
- 31
- watcher 数
- 1
- fork 数
- 19
- issue 数
- 9
- 最終更新
- 2024/08/06
主要言語: TypeScript
add postgres upsert mutations to postgraphile :elephant:
Add postgres upsert mutations to postgraphile.
pnpm install --save postgraphile-upsert-plugin
postgraphile --append-plugins postgraphile-upsert-plugin:PgMutationUpsertPlugin
See here for more information about loading plugins with PostGraphile.
import express from "express"; import { postgraphile } from "postgraphile"; import { PgMutationUpsertPlugin } from "postgraphile-upsert-plugin"; const app = express(); app.use( postgraphile(pgConfig, schema, { appendPlugins: [PgMutationUpsertPlugin], }) ); app.listen(5000);
This plugin supports an optional where clause in your upsert<Table> mutation. Supports multi-column unique indexes.
create table bikes ( id serial primary key, make varchar, model varchar serial_number varchar unique not null, weight real )
A basic upsert would look like this:
mutation { upsertBike( where: { serial_number: "abc123" } input: { bike: { make: "kona" model: "kula deluxe" serial_number: "abc123" weight: 25.6 } } ) { clientMutationId } }
@omit updateOnConflict to column comments to prevent them from being modified on existing rows in an upsert mutation.See CONTRIBUTING.md.