3.3.0 • Published 9 months ago

postgraphile-upsert-plugin v3.3.0

Weekly downloads
506
License
MIT
Repository
github
Last release
9 months ago

postgraphile-upsert-plugin

Add postgres upsert mutations to postgraphile.

semantic-release main

Getting Started

Install

pnpm install --save postgraphile-upsert-plugin

CLI

postgraphile --append-plugins postgraphile-upsert-plugin:PgMutationUpsertPlugin

See here for more information about loading plugins with PostGraphile.

Library

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);

Usage

This plugin supports an optional where clause in your upsert<Table> mutation. Supports multi-column unique indexes.

Example

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
  }
}

Smart Tags Support

  • Add @omit updateOnConflict to column comments to prevent them from being modified on existing rows in an upsert mutation.

Contributing

See CONTRIBUTING.md.

Credits

3.3.0

9 months ago

3.2.2

1 year ago

3.2.1

1 year ago

3.2.0

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

2.3.0

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.1

2 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.1.0

3 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.2

5 years ago