{"_id":"@brooklyn-labs/postgraphile-plugin-nested-mutations","_rev":"2-f6e24619fc0448e352bed276500b6d43","name":"@brooklyn-labs/postgraphile-plugin-nested-mutations","description":"Nested mutations plugin for PostGraphile","dist-tags":{"latest":"1.2.2"},"versions":{"1.2.1":{"name":"@brooklyn-labs/postgraphile-plugin-nested-mutations","version":"1.2.1","author":{"name":"Brooklyn Labs"},"license":"MIT","_id":"@brooklyn-labs/postgraphile-plugin-nested-mutations@1.2.1","maintainers":[{"name":"jkbjnsn","email":"jkbjnsn@outlook.com"},{"name":"andrisak","email":"andrisak@gmail.com"},{"name":"johnciprian","email":"brooklynlabs@icloud.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":"1de0a5bd960dd5b855733eeed4ffe8d79f45d145","tarball":"https://registry.npmjs.org/@brooklyn-labs/postgraphile-plugin-nested-mutations/-/postgraphile-plugin-nested-mutations-1.2.1.tgz","fileCount":9,"integrity":"sha512-7QNeAGYhEhBo2CzEe3u0gkqEJUvq40QVqdWePDCHLOzZWA4lajyNkcaJ9ZxYm6VNAGNh1HAHDGDai7fCe3OdGQ==","signatures":[{"sig":"MEUCIAOeVoiexsVJh7RSjS1BzL+PYBnEWnJlgSbAXshO7KeEAiEA69BkXk/7wM5HdZLGvvgnD63uvm2ZsGuwInkUOwSJgrM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":77063,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj5lydACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrfPA//Y2NUBx1WfhZ9fZ/Zv07535RD2gUyttr4nNPFqQ+AFDz2JQXu\r\nYlCdTYG2wdod3vwz49QE7c5gcT3PGABosWK6xmJ7bnNPSkV3t998Sxf9YIie\r\n0e6fY4skTK/hAqkp7HIjCK2seAsDyC0QLZTzN5Z2vae59PSCN4iX1O3lqOJP\r\nvlcUFuRIL8b7THur1TJxGMUx0OLu8aj5LFISn9Xj/3FkfmGBEwnOffZ27xFL\r\nXqUmSkPwLE4OANUwmLefNxsKRP+CUJdSkx3g8ZqOROTEJKuzcB7pJt9RGLTG\r\nRpXJAtGU0jwnqTWEEBxCF3nzKtHKtpYKBHirxTh2CnBOh+Q76G9D5tq+MFjS\r\nfgPgR7v7njUWUKrMcJcsrk+64LF+AWEuP7mbXEL+/ybaX5AaLd9DzBqi0NSr\r\nsBbYQziofGlhw0s4b6EZ0Ik2li4/hM1YG++q44lo25pNExKSE+4WynNs7dLR\r\nyLyeBgkJDAtlFXk9QxhTwLcCENuoMKPVcltDBngRnbEDIwTAWF9PrEkcMNbZ\r\nCIqttBjeRL6DuhcPuzAn47y4mSZTSF7mrrYsIQ5HPGquS9o7PAeHeybZ7uZ+\r\nUFQzDnbg/MaF8eBbz+GjHT6LsnZeGsEarstkac2WDPHkvnDw05ZggWtcZ+n8\r\nfRP7bAbKJKRj7LaefSMpUV4CIB+xI1ul4A4=\r\n=coF3\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"testRegex":"__tests__/.*\\.test\\.js$","collectCoverageFrom":["src/*.js","index.js"]},"main":"index.js","gitHead":"e300d40ce58f03509f75145e9cc2983d4569ccb1","scripts":{"lint":"eslint index.js src/**/*.js","test":"scripts/test jest -i"},"_npmUser":{"name":"johnciprian","email":"brooklynlabs@icloud.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.19.3","description":"Nested mutations plugin for PostGraphile","directories":{},"_nodeVersion":"16.19.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_1676041373696_0.8343762412917735","host":"s3://npm-registry-packages"}},"1.2.2":{"name":"@brooklyn-labs/postgraphile-plugin-nested-mutations","version":"1.2.2","author":{"name":"Brooklyn Labs"},"license":"MIT","_id":"@brooklyn-labs/postgraphile-plugin-nested-mutations@1.2.2","maintainers":[{"name":"jkbjnsn","email":"jkbjnsn@outlook.com"},{"name":"andrisak","email":"andrisak@gmail.com"},{"name":"johnciprian","email":"brooklynlabs@icloud.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":"e966fe9abd3547b2908b78da52709e5d0d5646bb","tarball":"https://registry.npmjs.org/@brooklyn-labs/postgraphile-plugin-nested-mutations/-/postgraphile-plugin-nested-mutations-1.2.2.tgz","fileCount":9,"integrity":"sha512-Ypp4OXC+q8sIfPuwpmPFA14Ly98uAH8Ka3d84VBgwcfLgXC7zmiMrNdgwjFQT4xd0hX144esgWXxEH5HaDdatA==","signatures":[{"sig":"MEUCIQCyi+mAJDS61LamTJ4mmxUKp7337jB8OUAj6xebMZ1/iAIgby84bhFupwR0HeCNME294GEiRJGiXmSJ3F66G3h9gIY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":76924,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj5mfCACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrkgA/+PSyRmrn2GGlsvjMDid6aHKjCHmL81X8cKDGuFxIeTVtYfvz3\r\nW9jqpi333wv37ykPymc8Q3LZP0Quz29/qcLQJv+KylS1J8+NMGLhtEBf+SWo\r\nXlAQeViC0QUoztxqvGchI5Ilef1hYIJQMdiVEKKLFySZ9Nbti5aSZgIDJqBt\r\nRagYeHVY//ZyuN1bUFI2G5IFJMfy5hN2WNoTYTi8qWZ1QpFBraDsCHWiOVyT\r\nl/TtWsCrMK3flVRf+dJBtFds30gNAcscV/YRpXmIU3yWFGAuO2TJWpFWwaGv\r\n0EbFj3Uf2Tthp1J7rreoSS35zTlZoSAGOpCnlrjMLqR+evstNFimvy6aJWa7\r\nkmYNpTV7aVL8kZI92sl7dfBK8JEH0q1bwRMatWXLWw815PFMYp/r4guWQJcr\r\nSdZ44I5MSKUt+y4wt+ljcKXPVMf9qZUF01bP8f8k3G1qrwbM2OKZqLYLmWx0\r\nk/YQOqP2GvcuVeJvVaqM7u2G59S8huv8Mx1EtIgf3KMSgNJySQoV0IUJflKB\r\nT8kn9IrXrdNUp1eKeiQOy8aAzyZ6XLORwo9bpmJHV8C07Vf6B5cb72/FDA1/\r\nMZNsElEXVs7uX8RjQzree3v/OVFbsjEINE3roUISHE3PANx6uZHZKJNHOgki\r\nUwGIRECliJoWwI/++BGkbUtm5VLSrUNC7Ws=\r\n=30Zy\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"testRegex":"__tests__/.*\\.test\\.js$","collectCoverageFrom":["src/*.js","index.js"]},"main":"index.js","gitHead":"edb66fe283d17cdb619267f04b124aa4c7a25880","scripts":{"lint":"eslint index.js src/**/*.js","test":"scripts/test jest -i"},"_npmUser":{"name":"johnciprian","email":"brooklynlabs@icloud.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.19.3","description":"Nested mutations plugin for PostGraphile","directories":{},"_nodeVersion":"16.19.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.2_1676044225956_0.17166187664068833","host":"s3://npm-registry-packages"}}},"time":{"created":"2023-02-10T15:02:53.622Z","modified":"2024-06-19T18:19:52.073Z","1.2.1":"2023-02-10T15:02:53.887Z","1.2.2":"2023-02-10T15:50:26.116Z"},"maintainers":[{"email":"jkbjnsn@outlook.com","name":"jkbjnsn"},{"email":"andrisak@gmail.com","name":"andrisak"}],"author":{"name":"Brooklyn Labs"},"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":"# postgraphile-plugin-nested-mutations\n\n[![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/brooklyn-labs/postgraphile-plugin-nested-mutations/ci.yml?branch=master&label=Build)](https://github.com/brooklyn-labs/postgraphile-plugin-nested-mutations/actions/workflows/ci.yml)\n[![npm (scoped)](https://img.shields.io/npm/v/@brooklyn-labs/postgraphile-plugin-nested-mutations?label=NPM)](https://www.npmjs.com/package/@brooklyn-labs/postgraphile-plugin-nested-mutations)\n[![License](https://img.shields.io/github/license/brooklyn-labs/postgraphile-plugin-nested-mutations?label=License)](https://github.com/brooklyn-labs/postgraphile-plugin-nested-mutations/blob/master/LICENSE)\n\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"}