@vantreeseba/drizzle-graphql 6.0.0 → 7.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 +110 -3
- package/dist/README.md +110 -3
- package/dist/index.cjs +820 -384
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -1
- package/dist/index.d.ts +60 -1
- package/dist/index.js +726 -280
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -232,8 +232,14 @@ declare const drizzleExecutorKey: unique symbol;
|
|
|
232
232
|
* 2. When limit/offset args are present, falls back to a direct per-item query.
|
|
233
233
|
* 3. Otherwise batches all sibling resolver calls within the same GraphQL execution tick
|
|
234
234
|
* into a single IN-clause query, eliminating N+1 database round-trips.
|
|
235
|
+
*
|
|
236
|
+
* `nullOrdering` is the dialect's native `ORDER BY` placement for `NULL` — the keyset
|
|
237
|
+
* predicate behind a relation's `after` argument has to match it, or rows with a `NULL` in an
|
|
238
|
+
* ordered column would be skipped instead of paged through. It has no sensible default, so
|
|
239
|
+
* each dialect builder states it: `'nulls-largest'` for PostgreSQL, `'nulls-smallest'` for
|
|
240
|
+
* MySQL and SQLite.
|
|
235
241
|
*/
|
|
236
|
-
declare const createRelationResolverFactory: (db: any, tables: Record<string, Table>, filterCtx?: RelationFilterBase) => RelationResolverFactory;
|
|
242
|
+
declare const createRelationResolverFactory: (db: any, tables: Record<string, Table>, nullOrdering: NullOrdering, filterCtx?: RelationFilterBase) => RelationResolverFactory;
|
|
237
243
|
/**
|
|
238
244
|
* Compiles an `orderBy` argument into ORDER BY expressions, highest priority first.
|
|
239
245
|
*
|
|
@@ -275,6 +281,14 @@ interface RelationFilterContext {
|
|
|
275
281
|
*/
|
|
276
282
|
type RelationFilterBase = Pick<RelationFilterContext, 'tables' | 'relationMap'>;
|
|
277
283
|
declare const extractFilters: <TTable extends Table>(table: TTable, tableName: string, filters: Filters<TTable>, relationCtx?: RelationFilterContext) => SQL | undefined;
|
|
284
|
+
/**
|
|
285
|
+
* Where a dialect's default sort places NULLs relative to non-NULL values:
|
|
286
|
+
* - `nulls-largest` — PostgreSQL: NULLs sort as the largest values (last in ASC, first in DESC).
|
|
287
|
+
* - `nulls-smallest` — MySQL and SQLite: NULLs sort as the smallest values (first in ASC, last
|
|
288
|
+
* in DESC).
|
|
289
|
+
* The keyset predicate has to agree with the dialect's ORDER BY, so each builder passes its own.
|
|
290
|
+
*/
|
|
291
|
+
type NullOrdering = 'nulls-largest' | 'nulls-smallest';
|
|
278
292
|
/**
|
|
279
293
|
* Default for `config.onError`: keeps drizzle-graphql's own errors, which are written for
|
|
280
294
|
* the client, and replaces driver/database errors with a generic message. Their text names
|
|
@@ -669,6 +683,51 @@ type SchemaFeatures = {
|
|
|
669
683
|
* @default false
|
|
670
684
|
*/
|
|
671
685
|
nestedWrites?: boolean;
|
|
686
|
+
/**
|
|
687
|
+
* Operation inputs on the update `set`, so a column can be changed relative to its current
|
|
688
|
+
* value instead of only replaced.
|
|
689
|
+
*
|
|
690
|
+
* ```graphql
|
|
691
|
+
* updatePostsSingle(where: { id: { eq: "p1" } }, set: { views: { increment: 1 } }) { views }
|
|
692
|
+
* ```
|
|
693
|
+
*
|
|
694
|
+
* Every numeric column's field on `Update<Table>Input` becomes a `<Scalar>FieldUpdate`
|
|
695
|
+
* input carrying `set`, `increment`, `decrement`, `multiply` and `divide`; every array
|
|
696
|
+
* column's becomes a `<Scalar>ListFieldUpdate` carrying `set` and `push`. Exactly one
|
|
697
|
+
* operation per field, checked at resolve time. `set` is the explicit spelling of what the
|
|
698
|
+
* field did before, so `set: { views: 42 }` becomes `set: { views: { set: 42 } }`.
|
|
699
|
+
*
|
|
700
|
+
* The arithmetic happens in the database (`SET views = views + 1`), so a counter no longer
|
|
701
|
+
* needs a read-modify-write round trip and no longer loses concurrent updates. Rounding on
|
|
702
|
+
* an integer column, and division by zero, follow the database's own rules rather than
|
|
703
|
+
* being guarded here. Columns owned by a scalar override keep their plain type — an
|
|
704
|
+
* override owns what the column accepts.
|
|
705
|
+
*
|
|
706
|
+
* Off by default: it changes the type of every numeric and array field on every update
|
|
707
|
+
* input, which no existing document is written against.
|
|
708
|
+
*
|
|
709
|
+
* @default false
|
|
710
|
+
*/
|
|
711
|
+
fieldUpdateOperations?: boolean;
|
|
712
|
+
/**
|
|
713
|
+
* `update<Table>Count` / `delete<Table>Count` mutations — the same write as the plural
|
|
714
|
+
* `update<Table>` / `delete<Table>`, returning the number of rows affected instead of the
|
|
715
|
+
* rows themselves.
|
|
716
|
+
*
|
|
717
|
+
* ```graphql
|
|
718
|
+
* deletePostsCount(where: { published: { eq: false } }) # Int!
|
|
719
|
+
* ```
|
|
720
|
+
*
|
|
721
|
+
* A mass update or delete otherwise has to `RETURNING *` every row it touched purely so
|
|
722
|
+
* the caller can count them, which crosses the driver and is serialized through GraphQL
|
|
723
|
+
* for nothing. Each mutation is generated only when its plural counterpart is
|
|
724
|
+
* (`features.update` / `features.delete`), and honours `features.requireWhere`.
|
|
725
|
+
*
|
|
726
|
+
* Off unless asked for, so an existing schema does not grow new mutations on upgrade.
|
|
727
|
+
*
|
|
728
|
+
* @default false
|
|
729
|
+
*/
|
|
730
|
+
countMutations?: boolean;
|
|
672
731
|
/**
|
|
673
732
|
* Makes `where` non-null on the plural `update<Table>` / `delete<Table>` mutations, and
|
|
674
733
|
* rejects a `where` that collapses to no filters (e.g. `where: {}`), so a schema can rule
|
package/dist/index.d.ts
CHANGED
|
@@ -232,8 +232,14 @@ declare const drizzleExecutorKey: unique symbol;
|
|
|
232
232
|
* 2. When limit/offset args are present, falls back to a direct per-item query.
|
|
233
233
|
* 3. Otherwise batches all sibling resolver calls within the same GraphQL execution tick
|
|
234
234
|
* into a single IN-clause query, eliminating N+1 database round-trips.
|
|
235
|
+
*
|
|
236
|
+
* `nullOrdering` is the dialect's native `ORDER BY` placement for `NULL` — the keyset
|
|
237
|
+
* predicate behind a relation's `after` argument has to match it, or rows with a `NULL` in an
|
|
238
|
+
* ordered column would be skipped instead of paged through. It has no sensible default, so
|
|
239
|
+
* each dialect builder states it: `'nulls-largest'` for PostgreSQL, `'nulls-smallest'` for
|
|
240
|
+
* MySQL and SQLite.
|
|
235
241
|
*/
|
|
236
|
-
declare const createRelationResolverFactory: (db: any, tables: Record<string, Table>, filterCtx?: RelationFilterBase) => RelationResolverFactory;
|
|
242
|
+
declare const createRelationResolverFactory: (db: any, tables: Record<string, Table>, nullOrdering: NullOrdering, filterCtx?: RelationFilterBase) => RelationResolverFactory;
|
|
237
243
|
/**
|
|
238
244
|
* Compiles an `orderBy` argument into ORDER BY expressions, highest priority first.
|
|
239
245
|
*
|
|
@@ -275,6 +281,14 @@ interface RelationFilterContext {
|
|
|
275
281
|
*/
|
|
276
282
|
type RelationFilterBase = Pick<RelationFilterContext, 'tables' | 'relationMap'>;
|
|
277
283
|
declare const extractFilters: <TTable extends Table>(table: TTable, tableName: string, filters: Filters<TTable>, relationCtx?: RelationFilterContext) => SQL | undefined;
|
|
284
|
+
/**
|
|
285
|
+
* Where a dialect's default sort places NULLs relative to non-NULL values:
|
|
286
|
+
* - `nulls-largest` — PostgreSQL: NULLs sort as the largest values (last in ASC, first in DESC).
|
|
287
|
+
* - `nulls-smallest` — MySQL and SQLite: NULLs sort as the smallest values (first in ASC, last
|
|
288
|
+
* in DESC).
|
|
289
|
+
* The keyset predicate has to agree with the dialect's ORDER BY, so each builder passes its own.
|
|
290
|
+
*/
|
|
291
|
+
type NullOrdering = 'nulls-largest' | 'nulls-smallest';
|
|
278
292
|
/**
|
|
279
293
|
* Default for `config.onError`: keeps drizzle-graphql's own errors, which are written for
|
|
280
294
|
* the client, and replaces driver/database errors with a generic message. Their text names
|
|
@@ -669,6 +683,51 @@ type SchemaFeatures = {
|
|
|
669
683
|
* @default false
|
|
670
684
|
*/
|
|
671
685
|
nestedWrites?: boolean;
|
|
686
|
+
/**
|
|
687
|
+
* Operation inputs on the update `set`, so a column can be changed relative to its current
|
|
688
|
+
* value instead of only replaced.
|
|
689
|
+
*
|
|
690
|
+
* ```graphql
|
|
691
|
+
* updatePostsSingle(where: { id: { eq: "p1" } }, set: { views: { increment: 1 } }) { views }
|
|
692
|
+
* ```
|
|
693
|
+
*
|
|
694
|
+
* Every numeric column's field on `Update<Table>Input` becomes a `<Scalar>FieldUpdate`
|
|
695
|
+
* input carrying `set`, `increment`, `decrement`, `multiply` and `divide`; every array
|
|
696
|
+
* column's becomes a `<Scalar>ListFieldUpdate` carrying `set` and `push`. Exactly one
|
|
697
|
+
* operation per field, checked at resolve time. `set` is the explicit spelling of what the
|
|
698
|
+
* field did before, so `set: { views: 42 }` becomes `set: { views: { set: 42 } }`.
|
|
699
|
+
*
|
|
700
|
+
* The arithmetic happens in the database (`SET views = views + 1`), so a counter no longer
|
|
701
|
+
* needs a read-modify-write round trip and no longer loses concurrent updates. Rounding on
|
|
702
|
+
* an integer column, and division by zero, follow the database's own rules rather than
|
|
703
|
+
* being guarded here. Columns owned by a scalar override keep their plain type — an
|
|
704
|
+
* override owns what the column accepts.
|
|
705
|
+
*
|
|
706
|
+
* Off by default: it changes the type of every numeric and array field on every update
|
|
707
|
+
* input, which no existing document is written against.
|
|
708
|
+
*
|
|
709
|
+
* @default false
|
|
710
|
+
*/
|
|
711
|
+
fieldUpdateOperations?: boolean;
|
|
712
|
+
/**
|
|
713
|
+
* `update<Table>Count` / `delete<Table>Count` mutations — the same write as the plural
|
|
714
|
+
* `update<Table>` / `delete<Table>`, returning the number of rows affected instead of the
|
|
715
|
+
* rows themselves.
|
|
716
|
+
*
|
|
717
|
+
* ```graphql
|
|
718
|
+
* deletePostsCount(where: { published: { eq: false } }) # Int!
|
|
719
|
+
* ```
|
|
720
|
+
*
|
|
721
|
+
* A mass update or delete otherwise has to `RETURNING *` every row it touched purely so
|
|
722
|
+
* the caller can count them, which crosses the driver and is serialized through GraphQL
|
|
723
|
+
* for nothing. Each mutation is generated only when its plural counterpart is
|
|
724
|
+
* (`features.update` / `features.delete`), and honours `features.requireWhere`.
|
|
725
|
+
*
|
|
726
|
+
* Off unless asked for, so an existing schema does not grow new mutations on upgrade.
|
|
727
|
+
*
|
|
728
|
+
* @default false
|
|
729
|
+
*/
|
|
730
|
+
countMutations?: boolean;
|
|
672
731
|
/**
|
|
673
732
|
* Makes `where` non-null on the plural `update<Table>` / `delete<Table>` mutations, and
|
|
674
733
|
* rejects a `where` that collapses to no filters (e.g. `where: {}`), so a schema can rule
|