You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,16 @@
5
5
6
6
This plugin implements mutations that allow many creates, updates, and deletes in a single transaction.
7
7
8
+
## Roadmap
9
+
Work is ongoing, here's the plan:
10
+
11
+
-[ ] Add a test suite, CI, and better test example in the readme.
12
+
-[ ] Update smart comments with better functionality to include individual create, update, or delete mutations vs. including them all together.
13
+
-[ ] 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.
14
+
-[ ] Add input types for the many updates and delete mutations, to show required constraints vs. using the table patch types that do not.
15
+
-[ ] Add better returned payload options, preferably to return a list of modified records.
16
+
-[ ] Add support for node id based updates and deletes.
17
+
8
18
## Getting Started
9
19
10
20
View the [postgraphile docs](https://www.graphile.org/postgraphile/extending/#loading-additional-plugins) for information about loading the plugin via the CLI or as a NodeJS library.
@@ -27,18 +37,18 @@ You must use smart comments to enable the many create, update, and delete mutati
27
37
28
38
```sql
29
39
comment on table public."Test" is
30
-
E'@mncud The test table is just for showing this example with comments.';
40
+
E'@mncud\n The test table is just for showing this example with comments.';
31
41
```
32
42
33
43
## Usage
34
44
35
45
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.
36
46
37
47
### Creates
38
-
```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.
48
+
```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```.
39
49
40
50
### Updates
41
-
```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.
51
+
```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.
42
52
43
53
### Deletes
44
-
```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 within the patch items b/c that is what's used in the where clause to update the correct row.
54
+
```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).
0 commit comments