@vantreeseba/drizzle-graphql 12.0.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -104,8 +104,10 @@ as a preset:
104
104
  const { schema } = buildSchema(db, { typeNameMapper: 'singularize' })
105
105
  ```
106
106
 
107
- `tasks` then gives type `Task`, queries `tasks` (list) and `task` (single), mutations
108
- `createTasks` (array) and `createTask` (single), `updateTask`, `deleteTask`. Irregular
107
+ `tasks` then gives type `Task`, queries `tasks` (list) and `task` (single), and each write
108
+ as a pair named the same way: `createTasks` / `createTask`, `updateTasks` / `updateTask`,
109
+ `deleteTasks` / `deleteTask` — plural for the form that operates on a set of rows, singular
110
+ for the one that operates on exactly one. Irregular
109
111
  plurals go through `pluralize`, so `people` gives `Person` / `people` / `person` and
110
112
  `addresses` gives `Address` rather than the `addresss` a naive suffix would produce. A table
111
113
  key that is already singular is pluralized for the list side, and a capitalized key is
@@ -362,9 +364,9 @@ variants that carry their own disambiguator — `usersAggregate`, `usersGroupBy`
362
364
  The list and single suffixes cannot be identical unless a `typeNameMapper` is also given —
363
365
  `users` and `usersSingle` would otherwise collapse onto one field name, and `buildSchema`
364
366
  throws rather than generating a schema that silently drops one of them. With a mapper the
365
- plural and singular nouns keep the queries and the inserts apart, but the bulk update,
366
- delete and restore mutations are singular on both sides, so those three keep a `Single`
367
- suffix whenever the two configured suffixes are the same string.
367
+ plural and singular nouns keep every pair apart on their own, so both suffixes may be empty
368
+ and no operation carries a `Single` at all. A table the mapper returns `undefined` for is
369
+ back on the default naming and still needs the suffixes to differ.
368
370
 
369
371
  That check compares the configured suffixes, which is only part of what a name is made of.
370
372
  Every generated root field is also registered by name, and a build that puts two operations
@@ -381,7 +383,8 @@ import pluralize from 'pluralize'
381
383
  const { schema } = buildSchema(db, {
382
384
  typeNameMapper: (table) => ({ singular: pluralize.singular(table), plural: table }),
383
385
  })
384
- // type User; queries `users` / `user`; mutations `createUsers` / `createUser`
386
+ // type User; queries `users` / `user`; mutations `createUsers` / `createUser`,
387
+ // `updateUsers` / `updateUser`, `deleteUsers` / `deleteUser`
385
388
  ```
386
389
 
387
390
  Return `undefined` for any table that should keep its default naming.
@@ -1590,7 +1593,9 @@ mutation {
1590
1593
  ## Single-row update & delete
1591
1594
 
1592
1595
  Alongside the plural `update<Table>` / `delete<Table>` mutations, every table gets an
1593
- `update<Table>Single` / `delete<Table>Single` variant that targets exactly one row:
1596
+ `update<Table>Single` / `delete<Table>Single` variant that targets exactly one row. (Under a
1597
+ [`typeNameMapper`](#naming) the pair is separated by the noun instead — `updateUsers` /
1598
+ `updateUser` — and there is no `Single`.)
1594
1599
 
1595
1600
  ```graphql
1596
1601
  mutation {
@@ -1874,7 +1879,7 @@ to match on prose:
1874
1879
  ```json
1875
1880
  {
1876
1881
  "message": "'where' matched more than one row — nothing was written!",
1877
- "path": ["updateUser"],
1882
+ "path": ["updateUsersSingle"],
1878
1883
  "extensions": {
1879
1884
  "code": "DRIZZLE_MULTI_ROW_MATCH",
1880
1885
  "drizzle": { "table": "Users", "operation": "update", "field": "updateUsersSingle" }