{"_id":"@bklyn-labs/postgraphile-plugin-nested-mutations","_rev":"5-42d3e0cc9679233f82b5d13462bd7954","name":"@bklyn-labs/postgraphile-plugin-nested-mutations","description":"Nested mutations plugin for PostGraphile","dist-tags":{"latest":"1.2.1"},"versions":{"1.2.0":{"name":"@bklyn-labs/postgraphile-plugin-nested-mutations","version":"1.2.0","author":{"name":"Mark Lipscombe"},"license":"MIT","_id":"@bklyn-labs/postgraphile-plugin-nested-mutations@1.2.0","maintainers":[{"name":"andrisak","email":"andrisak@gmail.com"}],"homepage":"https://github.com/brooklyn-labs/postgraphile-plugin-nested-mutations#readme","bugs":{"url":"https://github.com/brooklyn-labs/postgraphile-plugin-nested-mutations/issues"},"dist":{"shasum":"d8540c248a22a91169133cd892eef564471f17ca","tarball":"https://registry.npmjs.org/@bklyn-labs/postgraphile-plugin-nested-mutations/-/postgraphile-plugin-nested-mutations-1.2.0.tgz","fileCount":9,"integrity":"sha512-oOmLNPs5vuUL4bQcwPU/D7eGZLI1jqM9/BiObebqHg8UrlYd12lR2zoDIIZ9ocenD3bTkGPEPe7jAigY3athuQ==","signatures":[{"sig":"MEYCIQC8s6GxW5U5p/fG1vy6jYxxtZP1Pwff7KRk7Pe1W1bKrwIhAL2EJ4LBL6iC8ZlDmReKRojVVManiZFkOusA0WUWDQbC","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":76338,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhEi+QCRA9TVsSAnZWagAAbVMP+wRLhkaxp/kJoFE8xa3i\n+Jx+aFLtYtVE+Is73Ho8VM9GCW+aADsRRsqmXLQuSOt7ATfDUfArFJfiG8Sz\nBCEgLi3RhwVrXJ1BRwbk8mwqdjGSbkPpQHy1NLE7rJuG6V5XjHzzmpj09PzI\nLkHaoZK2lEWoKWSie/R2XBuJ5A52QxBq3zLXvMtGB8ZI8EwKLhKu/XUVqqil\nI1LD0onyj4Aq8yabqx7bSiF4IYfkqOV1FuAaSX05CGZGPQ82bzVsReZhYQHX\nt8NeTxutQLsx5hNjN2YIxTOtz0+ym5xMNAH8sj95VwakSXF1MhCv3sD6ZyU0\nDXNxGfKEEnFy0ldZh+DH0GEGUlXWisoQ0PK+z7jRec1U2jh0+WVYBj8j5zkJ\nfNuF1Tzb1De+ZzZyF3JxN0K6cLSkvn1HvzU0i+xkUYECLjvcJFfwN0w5M61f\nAIVCBhfHQya2BM/qzkdcnnOkt0rxe/uREPAwoBleruQyQBD/W1HmFRfp0P+P\nMz37N8LQS+iiDHb8KIG+18PjAiHe5aY4hG75k6qwKg7J5UbiQbxChBVWFhwg\n/MhBgdl0avxko6PSZ5+kh0lQZu3Ydi0A2aumBt9RiiSYjBLSAMnFYAGM26LE\nQxcosjczm4XxldNVuX2RB+j2bjW8JUdpSDhyOP/LaUt/lJmH1TJ+C222+Vb7\nmFlD\r\n=EFk6\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"testRegex":"__tests__/.*\\.test\\.js$","collectCoverageFrom":["src/*.js","index.js"]},"main":"index.js","gitHead":"b5cfa0b59213c45d1ef2876be784d9025e2f7167","scripts":{"lint":"eslint index.js src/**/*.js","test":"scripts/test jest -i"},"_npmUser":{"name":"andrisak","email":"andrisak@gmail.com"},"prettier":{"semi":true,"arrowParens":"always","singleQuote":true,"trailingComma":"all"},"repository":{"url":"git+https://github.com/brooklyn-labs/postgraphile-plugin-nested-mutations.git","type":"git"},"_npmVersion":"7.20.3","description":"Nested mutations plugin for PostGraphile","directories":{},"_nodeVersion":"16.6.1","dependencies":{"graphile-build-pg":"^4.11.2"},"eslintConfig":{"env":{"jest":true},"rules":{"max-len":0,"no-alert":0,"no-console":0,"no-plusplus":0,"no-return-assign":["error","except-parens"],"import/extensions":0,"no-nested-ternary":0,"prettier/prettier":"error","symbol-description":0,"import/no-unresolved":0,"no-underscore-dangle":["error",{"allow":["_fields"]}],"prefer-destructuring":["error",{"array":false,"object":true}],"prefer-object-spread":0,"no-restricted-globals":0,"class-methods-use-this":0,"import/prefer-default-export":0,"import/no-extraneous-dependencies":0},"extends":["airbnb-base","prettier"],"globals":{"expect":false,"jasmine":false},"plugins":["prettier"]},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.5.1","jest":"^26.6.3","eslint":"^7.22.0","graphql":"^15.5.0","prettier":"^2.2.1","jest-junit":"^12.0.0","postgraphile-core":"^4.11.2","eslint-plugin-import":"^2.22.1","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^3.3.1","eslint-config-airbnb-base":"^14.2.1","@graphile-contrib/pg-simplify-inflector":"^6.1.0"},"peerDependencies":{"postgraphile-core":"^4.2.0"},"_npmOperationalInternal":{"tmp":"tmp/postgraphile-plugin-nested-mutations_1.2.0_1628581776564_0.36565626672787843","host":"s3://npm-registry-packages"}},"1.2.1":{"name":"@bklyn-labs/postgraphile-plugin-nested-mutations","version":"1.2.1","author":{"name":"Mark Lipscombe"},"license":"MIT","_id":"@bklyn-labs/postgraphile-plugin-nested-mutations@1.2.1","maintainers":[{"name":"jkbjnsn","email":"jkbjnsn@outlook.com"},{"name":"andrisak","email":"andrisak@gmail.com"}],"homepage":"https://github.com/brooklyn-labs/postgraphile-plugin-nested-mutations#readme","bugs":{"url":"https://github.com/brooklyn-labs/postgraphile-plugin-nested-mutations/issues"},"dist":{"shasum":"f9e9f7327586f6473f1d370bcb1adc005c8d1b3c","tarball":"https://registry.npmjs.org/@bklyn-labs/postgraphile-plugin-nested-mutations/-/postgraphile-plugin-nested-mutations-1.2.1.tgz","fileCount":9,"integrity":"sha512-kNqpq/Xog72almAfMz5MvFe+jrClGbxRFuapdSMWcKNzJ+TagOlRiE0n+AcR8vzvzGZphuHmmWH36d6eFUOocA==","signatures":[{"sig":"MEUCIGez56BXjFEeX9L/DFmncvaUCm70hYUjQgw7pS21ntOqAiEApy2m/UqS1/K/5ZYxv/B7G4HTW0lU4GRpENkDUBS9LSI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":76600,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJinacYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmprcQ//bK4dURHx7YhgqbKeUHQpQn8MAiFIEYvL3e8dhzfd1DXfY/S2\r\ndMQvydQrl+GfP/BfGqJQUhoAGpE3PIp4ZJ2Qp2pFxaYZTZFizz2ZvNaQ14IE\r\nd6lIt2aX72M/hTYexiBcGYRNVT6DBP8jHmxyqbIej0nQXhF+mDJzpWFaKF23\r\nrRh9lua9OSkh+D/OroT2OdKjpO+KS8IqT2l42LhFYMORxgm0U4mSPzdSKQQd\r\naxlFpLuiByEknPwpQbwYQQBQ72qbRAV2wslPxXkFA/+TryfVkuDHHioWe+TS\r\ny5vBgZyAl3sNnzKrI5yJEqDqRyWlPJ4mN8yq8f99TYctzljbMmXVVm3QDWAK\r\no41hnZjTnQByf37JSA6QSs/4sxYabZXbYF/q8GcD+rHUgcKbq8XGQLVuXevM\r\nv3JWRkX/J4PHUkU7jSrJmh1LCk14joqPhshNf/rRYE/+B6BV6hJ4Mp6MI/zT\r\nAY9NlNakJpDGyA591a77q8RE/AxXk/+Ht1hqnTd0lqCGbSBBCz2uDqMrdCZD\r\nx1wIybYT9T1n5s1NNgeHW1YlWYst0SWLuuiud4fdBxeAgAdR1E5QBL+UMPHi\r\nLVEaAYG/kG6A1Lc5Z65L1SwGG19QoUP+4RyKjcBCzmnfJCqj1RujnW2IKysj\r\nDtbTctKcHJQqeG4/tIZzs53EsJqS8gx1gRk=\r\n=6rHx\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"testRegex":"__tests__/.*\\.test\\.js$","collectCoverageFrom":["src/*.js","index.js"]},"main":"index.js","gitHead":"bf7281bd5710abbfc9995f3b4d9c20ef5f966f48","scripts":{"lint":"eslint index.js src/**/*.js","test":"scripts/test jest -i"},"_npmUser":{"name":"andrisak","email":"andrisak@gmail.com"},"prettier":{"semi":true,"arrowParens":"always","singleQuote":true,"trailingComma":"all"},"repository":{"url":"git+https://github.com/brooklyn-labs/postgraphile-plugin-nested-mutations.git","type":"git"},"_npmVersion":"8.5.5","description":"Nested mutations plugin for PostGraphile","directories":{},"_nodeVersion":"16.15.0","dependencies":{"graphile-build-pg":"^4.11.2"},"eslintConfig":{"env":{"jest":true},"rules":{"max-len":0,"no-alert":0,"no-console":0,"no-plusplus":0,"no-return-assign":["error","except-parens"],"import/extensions":0,"no-nested-ternary":0,"prettier/prettier":"error","symbol-description":0,"import/no-unresolved":0,"no-underscore-dangle":["error",{"allow":["_fields"]}],"prefer-destructuring":["error",{"array":false,"object":true}],"prefer-object-spread":0,"no-restricted-globals":0,"class-methods-use-this":0,"import/prefer-default-export":0,"import/no-extraneous-dependencies":0},"extends":["airbnb-base","prettier"],"globals":{"expect":false,"jasmine":false},"plugins":["prettier"]},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.5.1","jest":"^26.6.3","eslint":"^7.22.0","graphql":"^15.5.0","prettier":"^2.2.1","jest-junit":"^12.0.0","postgraphile-core":"^4.11.2","eslint-plugin-import":"^2.22.1","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^3.3.1","eslint-config-airbnb-base":"^14.2.1","@graphile-contrib/pg-simplify-inflector":"^6.1.0"},"peerDependencies":{"postgraphile-core":"^4.2.0"},"_npmOperationalInternal":{"tmp":"tmp/postgraphile-plugin-nested-mutations_1.2.1_1654499096300_0.03506112950407747","host":"s3://npm-registry-packages"}}},"time":{"created":"2021-08-10T07:49:36.524Z","modified":"2024-06-19T18:20:53.035Z","1.2.0":"2021-08-10T07:49:36.700Z","1.2.1":"2022-06-06T07:04:56.492Z"},"maintainers":[{"email":"jkbjnsn@outlook.com","name":"jkbjnsn"},{"email":"andrisak@gmail.com","name":"andrisak"}],"author":{"name":"Mark Lipscombe"},"repository":{"url":"git+https://github.com/brooklyn-labs/postgraphile-plugin-nested-mutations.git","type":"git"},"license":"MIT","homepage":"https://github.com/brooklyn-labs/postgraphile-plugin-nested-mutations#readme","bugs":{"url":"https://github.com/brooklyn-labs/postgraphile-plugin-nested-mutations/issues"},"readme":"[![Package on npm](https://img.shields.io/npm/v/postgraphile-plugin-nested-mutations.svg)](https://www.npmjs.com/package/postgraphile-plugin-nested-mutations)\n[![CircleCI](https://circleci.com/gh/mlipscombe/postgraphile-plugin-nested-mutations/tree/master.svg?style=svg)](https://circleci.com/gh/mlipscombe/postgraphile-plugin-nested-mutations/tree/master)\n\n# postgraphile-plugin-nested-mutations\nThis plugin implements nested mutations based on both forward and reverse foreign\nkey relationships in PostGraphile v4.  Nested mutations can be of infinite depth.\n\n## Getting Started\n\n### CLI\n\n``` bash\npostgraphile --append-plugins postgraphile-plugin-nested-mutations\n```\n\nSee [here](https://www.graphile.org/postgraphile/extending/#loading-additional-plugins) for\nmore information about loading plugins with PostGraphile.\n\n### Library\n\n``` js\nconst express = require('express');\nconst { postgraphile } = require('postgraphile');\nconst PostGraphileNestedMutations = require('postgraphile-plugin-nested-mutations');\n\nconst app = express();\n\napp.use(\n  postgraphile(pgConfig, schema, {\n    appendPlugins: [\n      PostGraphileNestedMutations,\n    ],\n  })\n);\n\napp.listen(5000);\n```\n\n### Plugin Options\n\nWhen using PostGraphile as a library, the following plugin options can be passed \nvia `graphileBuildOptions`:\n\n<details>\n\n<summary>nestedMutationsSimpleFieldNames</summary>\n\nUse simple field names for nested mutations.  Instead of names suffixed with\n`tableBy<Key>` and `tableUsing<Key>`, tables with a single foreign key relationship \nbetween them will have their nested relation fields named `table`.  Defaults to\n`false`.\n\n```js\npostgraphile(pgConfig, schema, {\n  graphileBuildOptions: {\n    nestedMutationsSimpleFieldNames: true,\n  }\n});\n```\n</details>\n\n<details>\n\n<summary>nestedMutationsDeleteOthers</summary>\n\nControls whether the `deleteOthers` field is available on nested mutations.  Defaults\nto `true`.\n\n```js\npostgraphile(pgConfig, schema, {\n  graphileBuildOptions: {\n    nestedMutationsDeleteOthers: false,\n  }\n});\n```\n</details>\n\n<details>\n\n<summary>nestedMutationsOldUniqueFields</summary>\n\nIf enabled, plural names for one-to-one relations will be used.  For backwards\ncompatibility.  Defaults to `false`.\n\n```js\npostgraphile(pgConfig, schema, {\n  graphileBuildOptions: {\n    nestedMutationsOldUniqueFields: false,\n  }\n});\n```\n\n</details>\n\n## Usage\n\nThis plugin creates an additional field on each GraphQL `Input` type for every forward\nand reverse foreign key relationship on a table, with the same name as the foreign table.\n\nEach nested mutation field will have the following fields. They will accept an array if\nthe relationship is a one-to-many relationship, or a single input if they are one-to-one.\n\n### Connect to Existing Record\n#### `connectByNodeId`\nConnect using a `nodeId` from the nested table.\n\n#### `connectBy<K>`\nConnect using any readable primary key or unique constraint on the nested table.\n\n### Creating New Records\n#### `create`\nCreate a new record in the nested table.\n\n### Delete existing Record\n#### `deleteByNodeId`\nDelete using a `nodeId` from the nested table.\n\n#### `deleteBy<K>`\nDelete using any readable primary key or unique constraint on the nested table.\n\n### Updating Records\n#### `updateByNodeId`\nUpdate a record using a `nodeId` from the nested table.\n\n#### `updatedBy<K>`\nUpdate a record using any readable primary key or unique constraint on the nested table.\n\n## Example\n\n```sql\ncreate table parent (\n  id serial primary key,\n  name text not null\n);\n\ncreate table child (\n  id serial primary key,\n  parent_id integer,\n  name text not null,\n  constraint child_parent_fkey foreign key (parent_id)\n    references p.parent (id)\n);\n```\n\nA nested mutation against this schema, using `Parent` as the base mutation\nwould look like this:\n\n``` graphql\nmutation {\n  createParent(input: {\n    parent: {\n      name: \"Parent 1\"\n      childrenUsingId: {\n        connectById: [{\n          id: 1\n        }]\n        create: [{\n          name: \"Child 1\"\n        }, {\n          name: \"Child 2\"\n        }]\n      }\n    }\n  }) {\n    parent {\n      id\n      name\n      childrenByParentId {\n        nodes {\n          id\n          name\n        }\n      }\n    }\n  }\n}\n```\n\nOr using `Child` as the base mutation:\n\n``` graphql\nmutation {\n  createChild(input: {\n    child: {\n      name: \"Child 1\"\n      parentToParentId: {\n        create: {\n          name: \"Parent of Child 1\"\n        }\n      }\n    },\n  }) {\n    child {\n      id\n      name\n      parentByParentId {\n        id\n        name\n      }\n    }\n  }\n}\n```\n\n## Smart Comments\n\n[Smart comments](https://www.graphile.org/postgraphile/smart-comments/) are supported for \nrenaming the nested mutation fields.\n\n```sql\ncomment on constraint child_parent_fkey on child is\n  E'@fieldName parent\\n@foreignFieldName children';\n```\n","readmeFilename":"README.md"}