Sign inDemoInstall


Package Overview
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies



Version published




npm PRs Welcome

This plugin implements mutations that allow many creates, updates, and deletes in a single transaction.

To support, Please 🌟 if you used / like this library.


Here's the plan:

  • Add a test suite, CI, and better test example in the readme.
  • Update smart comments with better functionality to include individual create, update, or delete mutations vs. including them all together.
  • Add plugin options that allow conflict handling for inserts. This would allow updates (upsert), no action, failures (current default) based off the constraints or further options.
  • Add input types for the many updates and delete mutations, to show required constraints vs. using the table patch types that do not.
  • Add better returned payload options, preferably to return a list of modified records.
  • Add support for node id based updates and deletes.

Getting Started

View the postgraphile docs for information about loading the plugin via the CLI or as a NodeJS library.

Plugin Options

This plugin respects the default option to disable mutations all together via graphileBuildOptions.

postgraphile(pgConfig, schema, {
  graphileBuildOptions: {
    pgDisableDefaultMutations: true

Smart Comments

You must use smart comments to enable the many create, update, and delete mutations for a table, since they are not enabled by default to prevent crowding with the other autogenerated postgraphile default mutations. The single tag @mncud is all that's needed.

comment on table public."Test" is
  E'@mncud\n The test table is just for showing this example with comments.';


The plugin creates new mutations that allow you to batch create, update, and delete items from a given table. It works with primary keys for updates and deletes using the input patch that postgraphile generates. All creates, updates, and deletes have scoped names with "mn" in front of the mutation name to prevent conflicts with other mutations.


mnCreateTest would be an example mutation name, and we'll say it has attributes of test1 (a boolean), and name (a varchar). You'll see the required input has the clientMutationId and also a field called mnTest, where mnTest will take an array of items that use the table input type. Since it uses the table input type, the required items are all listed as expected. When creating records, any attributes left off will have their values set to default.


mnUpdateTestByName would be the update example name, assuming the name is the primary key. Updates have a required input with the clientMutatationId and a patch. The patch field accepts an array of table patch items. You MUST provide the primary key within the patch items b/c that is what's used in the where clause to update the correct row(s). Attributes that are not provided in the list of provided values, will not be updated. With that said, you can update different attributes in one record and leave them off in another and it will update both as expected.


mnDeleteTestByName would be the delete example name. Deletes have a required input with the clientMutationId and a patch. The patch field accepts an array of table patch items, but only the primary key items are used. You MUST provide the primary key(s) within the patch items b/c that is what's used in the where clause to delete the correct row(s).


  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request.





Last updated on 04 May 2022

Did you know?


Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.


Related posts

SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap


Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc