@vantreeseba/drizzle-graphql 4.0.0 → 4.2.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/dist/index.d.cts CHANGED
@@ -400,6 +400,13 @@ type GeneratedData<TDatabase extends AnyDrizzleDB<any>> = {
400
400
  type SchemaFeatures = {
401
401
  /** `<plural>Aggregate` root queries and the aggregate output types. @default true */
402
402
  aggregates?: boolean;
403
+ /**
404
+ * `<plural>GroupBy` root queries — the same aggregates, one row per group. Requires
405
+ * `aggregates`, whose output types the grouped result reuses.
406
+ *
407
+ * @default true
408
+ */
409
+ groupBy?: boolean;
403
410
  /** `<relation>Aggregate` fields on object types, for to-many relations. @default true */
404
411
  relationAggregates?: boolean;
405
412
  /** The `distinct` argument on list queries. @default true */
@@ -419,6 +426,26 @@ type SchemaFeatures = {
419
426
  */
420
427
  upsert?: boolean;
421
428
  };
429
+ /**
430
+ * Per-field cost hints for `graphql-query-complexity` (or any estimator that reads
431
+ * `extensions.complexity`). See {@link BuildSchemaConfig.complexity}.
432
+ */
433
+ type ComplexityConfig = {
434
+ /**
435
+ * Rows a list field is assumed to return when the query passes no `limit`. Raise it if your
436
+ * tables are large and clients routinely omit `limit`.
437
+ *
438
+ * @default 10
439
+ */
440
+ defaultListSize?: number;
441
+ /**
442
+ * Flat cost charged for an aggregate field, on top of whatever is selected inside it. An
443
+ * aggregate returns one row but reads however many match, so it is priced as a scan.
444
+ *
445
+ * @default 10
446
+ */
447
+ aggregateCost?: number;
448
+ };
422
449
  type BuildSchemaConfig = {
423
450
  /**
424
451
  * Determines whether generated mutations will be passed to returned schema.
@@ -487,6 +514,31 @@ type BuildSchemaConfig = {
487
514
  * until the next major.
488
515
  */
489
516
  conflictDoNothing?: boolean;
517
+ /**
518
+ * Cost hints published as `extensions.complexity` on the generated fields, for
519
+ * `graphql-query-complexity`'s `fieldExtensionsEstimator`.
520
+ *
521
+ * The generator knows which fields are paginated and which are aggregates, so a list field is
522
+ * priced at `(limit ?? defaultListSize) * childComplexity` and an aggregate at
523
+ * `aggregateCost + childComplexity`. Everything else is left alone and falls through to your
524
+ * estimator's default. The hints are inert until you install a complexity rule, so they are on
525
+ * by default; pass `false` to omit them.
526
+ *
527
+ * Cost is not a depth bound — a cyclic relation graph still lets a client nest arbitrarily
528
+ * deep. Put a depth limit in front of a publicly exposed schema as well.
529
+ *
530
+ * ```ts
531
+ * import { createComplexityRule, fieldExtensionsEstimator, simpleEstimator } from 'graphql-query-complexity';
532
+ *
533
+ * const rule = createComplexityRule({
534
+ * maximumComplexity: 1000,
535
+ * estimators: [fieldExtensionsEstimator(), simpleEstimator({ defaultComplexity: 1 })],
536
+ * });
537
+ * ```
538
+ *
539
+ * @default true
540
+ */
541
+ complexity?: boolean | ComplexityConfig;
490
542
  /**
491
543
  * Turns individual generated features off.
492
544
  *
@@ -594,4 +646,4 @@ declare const GraphQLBigIntString: GraphQLScalarType<string, string>;
594
646
 
595
647
  declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
596
648
 
597
- export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, type DeleteResolver, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedOutputs, GraphQLBigIntString, type InsertArrResolver, type InsertResolver, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationResolverFactory, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableNamedRelations, type UpdateResolver, type UpsertArgs, type UpsertArrResolver, type UpsertConflictArgs, type UpsertResolver, buildSchema, createRelationResolverFactory, defaultErrorMapper, drizzleExecutorKey, extractFilters, extractOrderBy, extractRelationJoinColumns };
649
+ export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, type ComplexityConfig, type DeleteResolver, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedOutputs, GraphQLBigIntString, type InsertArrResolver, type InsertResolver, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationResolverFactory, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableNamedRelations, type UpdateResolver, type UpsertArgs, type UpsertArrResolver, type UpsertConflictArgs, type UpsertResolver, buildSchema, createRelationResolverFactory, defaultErrorMapper, drizzleExecutorKey, extractFilters, extractOrderBy, extractRelationJoinColumns };
package/dist/index.d.ts CHANGED
@@ -400,6 +400,13 @@ type GeneratedData<TDatabase extends AnyDrizzleDB<any>> = {
400
400
  type SchemaFeatures = {
401
401
  /** `<plural>Aggregate` root queries and the aggregate output types. @default true */
402
402
  aggregates?: boolean;
403
+ /**
404
+ * `<plural>GroupBy` root queries — the same aggregates, one row per group. Requires
405
+ * `aggregates`, whose output types the grouped result reuses.
406
+ *
407
+ * @default true
408
+ */
409
+ groupBy?: boolean;
403
410
  /** `<relation>Aggregate` fields on object types, for to-many relations. @default true */
404
411
  relationAggregates?: boolean;
405
412
  /** The `distinct` argument on list queries. @default true */
@@ -419,6 +426,26 @@ type SchemaFeatures = {
419
426
  */
420
427
  upsert?: boolean;
421
428
  };
429
+ /**
430
+ * Per-field cost hints for `graphql-query-complexity` (or any estimator that reads
431
+ * `extensions.complexity`). See {@link BuildSchemaConfig.complexity}.
432
+ */
433
+ type ComplexityConfig = {
434
+ /**
435
+ * Rows a list field is assumed to return when the query passes no `limit`. Raise it if your
436
+ * tables are large and clients routinely omit `limit`.
437
+ *
438
+ * @default 10
439
+ */
440
+ defaultListSize?: number;
441
+ /**
442
+ * Flat cost charged for an aggregate field, on top of whatever is selected inside it. An
443
+ * aggregate returns one row but reads however many match, so it is priced as a scan.
444
+ *
445
+ * @default 10
446
+ */
447
+ aggregateCost?: number;
448
+ };
422
449
  type BuildSchemaConfig = {
423
450
  /**
424
451
  * Determines whether generated mutations will be passed to returned schema.
@@ -487,6 +514,31 @@ type BuildSchemaConfig = {
487
514
  * until the next major.
488
515
  */
489
516
  conflictDoNothing?: boolean;
517
+ /**
518
+ * Cost hints published as `extensions.complexity` on the generated fields, for
519
+ * `graphql-query-complexity`'s `fieldExtensionsEstimator`.
520
+ *
521
+ * The generator knows which fields are paginated and which are aggregates, so a list field is
522
+ * priced at `(limit ?? defaultListSize) * childComplexity` and an aggregate at
523
+ * `aggregateCost + childComplexity`. Everything else is left alone and falls through to your
524
+ * estimator's default. The hints are inert until you install a complexity rule, so they are on
525
+ * by default; pass `false` to omit them.
526
+ *
527
+ * Cost is not a depth bound — a cyclic relation graph still lets a client nest arbitrarily
528
+ * deep. Put a depth limit in front of a publicly exposed schema as well.
529
+ *
530
+ * ```ts
531
+ * import { createComplexityRule, fieldExtensionsEstimator, simpleEstimator } from 'graphql-query-complexity';
532
+ *
533
+ * const rule = createComplexityRule({
534
+ * maximumComplexity: 1000,
535
+ * estimators: [fieldExtensionsEstimator(), simpleEstimator({ defaultComplexity: 1 })],
536
+ * });
537
+ * ```
538
+ *
539
+ * @default true
540
+ */
541
+ complexity?: boolean | ComplexityConfig;
490
542
  /**
491
543
  * Turns individual generated features off.
492
544
  *
@@ -594,4 +646,4 @@ declare const GraphQLBigIntString: GraphQLScalarType<string, string>;
594
646
 
595
647
  declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
596
648
 
597
- export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, type DeleteResolver, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedOutputs, GraphQLBigIntString, type InsertArrResolver, type InsertResolver, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationResolverFactory, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableNamedRelations, type UpdateResolver, type UpsertArgs, type UpsertArrResolver, type UpsertConflictArgs, type UpsertResolver, buildSchema, createRelationResolverFactory, defaultErrorMapper, drizzleExecutorKey, extractFilters, extractOrderBy, extractRelationJoinColumns };
649
+ export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, type ComplexityConfig, type DeleteResolver, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedOutputs, GraphQLBigIntString, type InsertArrResolver, type InsertResolver, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationResolverFactory, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableNamedRelations, type UpdateResolver, type UpsertArgs, type UpsertArrResolver, type UpsertConflictArgs, type UpsertResolver, buildSchema, createRelationResolverFactory, defaultErrorMapper, drizzleExecutorKey, extractFilters, extractOrderBy, extractRelationJoinColumns };