@vantreeseba/drizzle-graphql 10.0.3 → 11.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
@@ -353,9 +353,23 @@ const { schema } = buildSchema(db, {
353
353
  })
354
354
  ```
355
355
 
356
+ Both suffixes reach every operation that comes in a list/single pair, mutations included:
357
+ the config above gives `usersAll` / `users` on the query side and `addUsersAll` / `addUsers`,
358
+ `editUsersAll` / `editUsers`, `removeUsersAll` / `removeUsers` on the mutation side. The
359
+ variants that carry their own disambiguator — `usersAggregate`, `usersGroupBy`,
360
+ `updateUsersMany`, `updateUsersCount`, `deleteUsersCount` — take neither suffix.
361
+
356
362
  The list and single suffixes cannot be identical unless a `typeNameMapper` is also given —
357
363
  `users` and `usersSingle` would otherwise collapse onto one field name, and `buildSchema`
358
- throws rather than generating a schema that silently drops one of them.
364
+ 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.
368
+
369
+ That check compares the configured suffixes, which is only part of what a name is made of.
370
+ Every generated root field is also registered by name, and a build that puts two operations
371
+ on one field name throws naming the field rather than dropping whichever registered first —
372
+ whatever combination of prefixes, suffixes and mapper produced it.
359
373
 
360
374
  `typeNameMapper` renames the table itself, which is what a plural-keyed schema usually wants:
361
375
  `export const users = pgTable('users', …)` otherwise produces `type Users` and a
package/dist/index.cjs CHANGED
@@ -3569,6 +3569,7 @@ const generateWriteCount = ({ db, tableName, table, kind, setArgs, filterArgs, f
3569
3569
  //#endregion
3570
3570
  //#region src/util/batch-loader/index.ts
3571
3571
  const DRIZZLE_LOADERS_KEY = Symbol("drizzle-graphql-loaders");
3572
+ const DRIZZLE_REQUEST_CACHE_KEY = Symbol("drizzle-graphql-request-cache");
3572
3573
  var BatchLoader = class {
3573
3574
  batchFn;
3574
3575
  batch = [];
@@ -3612,6 +3613,32 @@ const getOrCreateLoader = (context, key, batchFn) => {
3612
3613
  if (!loaders.has(key)) loaders.set(key, new BatchLoader(batchFn));
3613
3614
  return loaders.get(key);
3614
3615
  };
3616
+ /**
3617
+ * Memoizes a value that a resolver derives from its own field — its args and its selection —
3618
+ * for the length of one request. Resolvers run once per parent row, so anything derived only
3619
+ * from the field is otherwise recomputed for every row of a batch.
3620
+ *
3621
+ * The cache lives on the context (weakly keyed by the AST node the value is derived from, so a
3622
+ * document cached across requests never carries values between them) and `key` separates fields
3623
+ * that share a node: one fragment selection can resolve for more than one parent type. Without a
3624
+ * context object there is nowhere request-scoped to cache, so the value is simply computed.
3625
+ *
3626
+ * `compute` must not read the parent row.
3627
+ */
3628
+ const getOrCreateRequestValue = (context, node, key, compute) => {
3629
+ if (!context || typeof context !== "object" || !node || typeof node !== "object") return compute();
3630
+ if (!context[DRIZZLE_REQUEST_CACHE_KEY]) context[DRIZZLE_REQUEST_CACHE_KEY] = /* @__PURE__ */ new WeakMap();
3631
+ const cache = context[DRIZZLE_REQUEST_CACHE_KEY];
3632
+ let entries = cache.get(node);
3633
+ if (!entries) {
3634
+ entries = /* @__PURE__ */ new Map();
3635
+ cache.set(node, entries);
3636
+ }
3637
+ if (entries.has(key)) return entries.get(key);
3638
+ const value = compute();
3639
+ entries.set(key, value);
3640
+ return value;
3641
+ };
3615
3642
  //#endregion
3616
3643
  //#region src/util/extensions.ts
3617
3644
  /**
@@ -3829,30 +3856,40 @@ const createRelationResolverFactory = (db, tables, nullOrdering, filterCtx, limi
3829
3856
  const localValue = parent[localColPropName];
3830
3857
  if (localValue == null) return isOne ? null : [];
3831
3858
  const { where: whereArg, limit: requestedLimit, offset, after, deleted } = args ?? {};
3832
- const orderByArg = isOne ? args?.orderBy : withDefaultOrderBy(args ?? {}, targetTableName, policies?.defaultOrderBy).orderBy;
3833
- const limit = applyLimitPolicy(requestedLimit, limitPolicy, errorCtx);
3834
- const distinct = (args ?? {}).distinct?.length ? (args ?? {}).distinct : void 0;
3835
- const cursorSelected = !isOne && !!info && selectsCursorField(info, targetTable);
3836
- let cursorEntries;
3837
- if (!isOne && (after != null || cursorSelected)) {
3838
- if (after != null && distinct) throw drizzleError("'after' cannot be combined with 'distinct'.", { code: "DRIZZLE_INVALID_CURSOR" });
3839
- if (orderByHasRelationEntry(orderByArg)) {
3840
- if (after != null) throw drizzleError("'after' cannot be combined with an orderBy that orders through a relation — a related row's value cannot be encoded into a cursor.", { code: "DRIZZLE_INVALID_CURSOR" });
3841
- } else if (!targetPkNames.length) {
3842
- if (after != null) throw drizzleError(`Table ${targetTableName} has no primary key, so cursor pagination cannot be used on it.`, { code: "DRIZZLE_INVALID_CURSOR" });
3843
- } else cursorEntries = cursorOrderingEntries(orderByArg, targetPkNames);
3844
- }
3845
- const cursorValues = after != null && cursorEntries ? decodeCursor(after, cursorEntries) : void 0;
3846
- const loaderKey = `${tableName}::${relationName}::${JSON.stringify({
3847
- where: whereArg ?? null,
3848
- orderBy: orderByArg ?? null,
3849
- limit: limit ?? null,
3850
- offset: offset ?? null,
3851
- deleted: deleted ?? defaultDeleted ?? null,
3852
- after: after ?? null,
3853
- distinct: distinct ?? null,
3854
- cursor: cursorEntries ? 1 : 0
3855
- })}`;
3859
+ const { orderByArg, limit, distinct, cursorEntries, cursorValues, loaderKey } = getOrCreateRequestValue(context, info?.fieldNodes?.[0], `relation:${tableName}::${relationName}`, () => {
3860
+ const orderByArg = isOne ? args?.orderBy : withDefaultOrderBy(args ?? {}, targetTableName, policies?.defaultOrderBy).orderBy;
3861
+ const limit = applyLimitPolicy(requestedLimit, limitPolicy, errorCtx);
3862
+ const distinct = (args ?? {}).distinct?.length ? (args ?? {}).distinct : void 0;
3863
+ const cursorSelected = !isOne && !!info && selectsCursorField(info, targetTable);
3864
+ let cursorEntries;
3865
+ if (!isOne && (after != null || cursorSelected)) {
3866
+ if (after != null && distinct) throw drizzleError("'after' cannot be combined with 'distinct'.", { code: "DRIZZLE_INVALID_CURSOR" });
3867
+ if (orderByHasRelationEntry(orderByArg)) {
3868
+ if (after != null) throw drizzleError("'after' cannot be combined with an orderBy that orders through a relation — a related row's value cannot be encoded into a cursor.", { code: "DRIZZLE_INVALID_CURSOR" });
3869
+ } else if (!targetPkNames.length) {
3870
+ if (after != null) throw drizzleError(`Table ${targetTableName} has no primary key, so cursor pagination cannot be used on it.`, { code: "DRIZZLE_INVALID_CURSOR" });
3871
+ } else cursorEntries = cursorOrderingEntries(orderByArg, targetPkNames);
3872
+ }
3873
+ const cursorValues = after != null && cursorEntries ? decodeCursor(after, cursorEntries) : void 0;
3874
+ const argsKey = JSON.stringify({
3875
+ where: whereArg ?? null,
3876
+ orderBy: orderByArg ?? null,
3877
+ limit: limit ?? null,
3878
+ offset: offset ?? null,
3879
+ deleted: deleted ?? defaultDeleted ?? null,
3880
+ after: after ?? null,
3881
+ distinct: distinct ?? null,
3882
+ cursor: cursorEntries ? 1 : 0
3883
+ });
3884
+ return {
3885
+ orderByArg,
3886
+ limit,
3887
+ distinct,
3888
+ cursorEntries,
3889
+ cursorValues,
3890
+ loaderKey: `${tableName}::${relationName}::${argsKey}`
3891
+ };
3892
+ });
3856
3893
  return getOrCreateLoader(context, loaderKey, async (parentIds) => {
3857
3894
  const executor = resolveExecutor(db, context);
3858
3895
  const uniqueIds = [...new Set(parentIds)];
@@ -3926,20 +3963,24 @@ const computeResolverFieldNames = (tableName, typeNameMapper, prefixes, suffixes
3926
3963
  const singleFieldName = mapped?.singular ?? uncapitalize(tableName) + suffixes.single;
3927
3964
  const aggregateFieldName = `${mapped?.plural ?? uncapitalize(tableName)}Aggregate`;
3928
3965
  const groupByFieldName = `${mapped?.plural ?? uncapitalize(tableName)}GroupBy`;
3929
- const createArrayFieldName = `${prefixes.insert}${mapped ? capitalize(mapped.plural) : capitalize(tableName)}`;
3966
+ const pluralNoun = mapped ? capitalize(mapped.plural) : capitalize(tableName);
3967
+ const singularNoun = mapped ? capitalize(mapped.singular) : capitalize(tableName);
3968
+ const createArrayFieldName = `${prefixes.insert}${pluralNoun}${suffixes.list}`;
3930
3969
  const createSingleFieldName = mapped ? `${prefixes.insert}${capitalize(mapped.singular)}` : `${prefixes.insert}${capitalize(tableName)}${suffixes.single}`;
3931
3970
  const upsertPrefix = prefixes.upsert ?? "upsert";
3932
- const upsertArrayFieldName = `${upsertPrefix}${mapped ? capitalize(mapped.plural) : capitalize(tableName)}`;
3971
+ const upsertArrayFieldName = `${upsertPrefix}${pluralNoun}${suffixes.list}`;
3933
3972
  const upsertSingleFieldName = mapped ? `${upsertPrefix}${capitalize(mapped.singular)}` : `${upsertPrefix}${capitalize(tableName)}${suffixes.single}`;
3934
- const updateFieldName = `${prefixes.update}${mapped ? capitalize(mapped.singular) : capitalize(tableName)}`;
3935
- const updateManyFieldName = `${prefixes.update}${mapped ? capitalize(mapped.plural) : capitalize(tableName)}Many`;
3936
- const deleteFieldName = `${prefixes.delete}${mapped ? capitalize(mapped.singular) : capitalize(tableName)}`;
3937
- const restoreFieldName = `${prefixes.restore ?? "restore"}${mapped ? capitalize(mapped.singular) : capitalize(tableName)}`;
3938
- const writeSingleSuffix = suffixes.single === "" ? "Single" : suffixes.single;
3939
- const updateSingleFieldName = `${updateFieldName}${writeSingleSuffix}`;
3940
- const deleteSingleFieldName = `${deleteFieldName}${writeSingleSuffix}`;
3941
- const restoreSingleFieldName = `${restoreFieldName}${writeSingleSuffix}`;
3942
- const pluralNoun = mapped ? capitalize(mapped.plural) : capitalize(tableName);
3973
+ const updateBase = `${prefixes.update}${singularNoun}`;
3974
+ const deleteBase = `${prefixes.delete}${singularNoun}`;
3975
+ const restoreBase = `${prefixes.restore ?? "restore"}${singularNoun}`;
3976
+ const updateFieldName = `${updateBase}${suffixes.list}`;
3977
+ const updateManyFieldName = `${prefixes.update}${pluralNoun}Many`;
3978
+ const deleteFieldName = `${deleteBase}${suffixes.list}`;
3979
+ const restoreFieldName = `${restoreBase}${suffixes.list}`;
3980
+ const writeSingleSuffix = suffixes.single === suffixes.list ? "Single" : suffixes.single;
3981
+ const updateSingleFieldName = `${updateBase}${writeSingleSuffix}`;
3982
+ const deleteSingleFieldName = `${deleteBase}${writeSingleSuffix}`;
3983
+ const restoreSingleFieldName = `${restoreBase}${writeSingleSuffix}`;
3943
3984
  return {
3944
3985
  typeName,
3945
3986
  listFieldName,
@@ -3962,6 +4003,26 @@ const computeResolverFieldNames = (tableName, typeNameMapper, prefixes, suffixes
3962
4003
  };
3963
4004
  };
3964
4005
  //#endregion
4006
+ //#region src/util/builders/common/root-fields.ts
4007
+ /**
4008
+ * Registers one generated root field, refusing to overwrite a name already taken.
4009
+ *
4010
+ * A generated name is the table name run through `typeNameMapper`, a prefix and a suffix,
4011
+ * and the pluralization each operation applies — so whether two operations collide is a
4012
+ * property of the finished names, not of any one piece of the config. `buildSchema` checks
4013
+ * what it can up front (identical list and single suffixes with no mapper), but that check
4014
+ * compares the suffix *strings*, which cannot see a collision the rest of the naming rules
4015
+ * produce: `{ list: 'All', single: '' }` used to give both insert mutations the name
4016
+ * `createUsers`, and the array insert simply disappeared from the schema.
4017
+ *
4018
+ * Assigning into the record silently kept the last registration. Throwing here means a
4019
+ * naming config that cannot work says so at build time, naming the field it lost.
4020
+ */
4021
+ const defineRootField = (fields, kind, name, config) => {
4022
+ if (Object.getOwnPropertyDescriptor(fields, name) !== void 0) throw new Error(`Drizzle-GraphQL Error: two generated ${kind} fields are both named '${name}'. Generated names come from the table name plus config.prefixes, config.suffixes and config.typeNameMapper — some combination of those gives two operations the same name. Adjust one of them so each operation gets its own.`);
4023
+ fields[name] = config;
4024
+ };
4025
+ //#endregion
3965
4026
  //#region src/util/builders/common/select-runtime.ts
3966
4027
  /**
3967
4028
  * Runs the relational-query-builder select shared by every dialect's `generateSelect*`
@@ -6324,7 +6385,7 @@ const createSchemaBuilder = (adapter) => {
6324
6385
  const groupByEnum = groupByType ? generateGroupByEnum(table, tableName, typeName, cacheCtx) : void 0;
6325
6386
  const havingInput = groupByEnum ? generateHavingInput(table, tableName, typeName, cacheCtx) : void 0;
6326
6387
  const groupByGenerated = groupByType && groupByEnum && havingInput ? generateGroupBy(db, tableName, table, typeName, groupByFieldName, tableFilters, groupByEnum, havingInput, filterCtx, tablePolicies, cacheCtx.typeName) : void 0;
6327
- ctx.queries[selectArrGenerated.name] = {
6388
+ defineRootField(ctx.queries, "query", selectArrGenerated.name, {
6328
6389
  type: selectArrOutput,
6329
6390
  args: selectArrGenerated.args,
6330
6391
  resolve: selectArrGenerated.resolver,
@@ -6337,8 +6398,8 @@ const createSchemaBuilder = (adapter) => {
6337
6398
  }),
6338
6399
  ...complexity ? { complexity: listFieldComplexity(complexity, limits?.(tableName)) } : {}
6339
6400
  }
6340
- };
6341
- ctx.queries[selectSingleGenerated.name] = {
6401
+ });
6402
+ defineRootField(ctx.queries, "query", selectSingleGenerated.name, {
6342
6403
  type: selectSingleOutput,
6343
6404
  args: selectSingleGenerated.args,
6344
6405
  resolve: selectSingleGenerated.resolver,
@@ -6348,8 +6409,8 @@ const createSchemaBuilder = (adapter) => {
6348
6409
  single: true,
6349
6410
  targetArg: "where"
6350
6411
  }) }
6351
- };
6352
- if (aggregateGenerated && aggregateType) ctx.queries[aggregateGenerated.name] = {
6412
+ });
6413
+ if (aggregateGenerated && aggregateType) defineRootField(ctx.queries, "query", aggregateGenerated.name, {
6353
6414
  type: new graphql.GraphQLNonNull(aggregateType),
6354
6415
  args: aggregateGenerated.args,
6355
6416
  resolve: aggregateGenerated.resolver,
@@ -6362,8 +6423,8 @@ const createSchemaBuilder = (adapter) => {
6362
6423
  }),
6363
6424
  ...complexity ? { complexity: aggregateFieldComplexity(complexity) } : {}
6364
6425
  }
6365
- };
6366
- if (groupByGenerated && groupByType) ctx.queries[groupByGenerated.name] = {
6426
+ });
6427
+ if (groupByGenerated && groupByType) defineRootField(ctx.queries, "query", groupByGenerated.name, {
6367
6428
  type: new graphql.GraphQLNonNull(new graphql.GraphQLList(new graphql.GraphQLNonNull(groupByType))),
6368
6429
  args: groupByGenerated.args,
6369
6430
  resolve: groupByGenerated.resolver,
@@ -6376,7 +6437,7 @@ const createSchemaBuilder = (adapter) => {
6376
6437
  }),
6377
6438
  ...complexity ? { complexity: aggregateFieldComplexity(complexity) } : {}
6378
6439
  }
6379
- };
6440
+ });
6380
6441
  return {
6381
6442
  aggregateType,
6382
6443
  groupByType,
@@ -6754,7 +6815,7 @@ const generateSchemaData$2 = (db, schema, relations, options) => {
6754
6815
  targetArg: "where"
6755
6816
  }]
6756
6817
  ];
6757
- for (const [generated, meta] of generatedMutations) if (generated) mutations[generated.name] = {
6818
+ for (const [generated, meta] of generatedMutations) if (generated) defineRootField(mutations, "mutation", generated.name, {
6758
6819
  type: mutationReturnType,
6759
6820
  args: generated.args,
6760
6821
  resolve: generated.resolver,
@@ -6762,19 +6823,19 @@ const generateSchemaData$2 = (db, schema, relations, options) => {
6762
6823
  kind: "mutation",
6763
6824
  ...meta
6764
6825
  }) }
6765
- };
6766
- if (updateCountGenerated) mutations[updateCountGenerated.name] = {
6826
+ });
6827
+ if (updateCountGenerated) defineRootField(mutations, "mutation", updateCountGenerated.name, {
6767
6828
  type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
6768
6829
  args: updateCountGenerated.args,
6769
6830
  resolve: updateCountGenerated.resolver,
6770
6831
  description: "How many rows the update touched. The rows themselves are not read back, which is the point of this mutation."
6771
- };
6772
- if (deleteCountGenerated) mutations[deleteCountGenerated.name] = {
6832
+ });
6833
+ if (deleteCountGenerated) defineRootField(mutations, "mutation", deleteCountGenerated.name, {
6773
6834
  type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
6774
6835
  args: deleteCountGenerated.args,
6775
6836
  resolve: deleteCountGenerated.resolver,
6776
6837
  description: "How many rows the delete removed. The rows themselves are not read back, which is the point of this mutation."
6777
- };
6838
+ });
6778
6839
  [
6779
6840
  ...tableFeatures.insert || onConflictInput ? [insertInput] : [],
6780
6841
  ...onConflictInput ? [onConflictInput] : [],
@@ -7220,7 +7281,7 @@ const createSchemaDataGenerator = (adapter) => {
7220
7281
  filterCtx,
7221
7282
  txCtx: mutationTxCtx
7222
7283
  }) : void 0;
7223
- if (insertArrGenerated) mutations[insertArrGenerated.name] = {
7284
+ if (insertArrGenerated) defineRootField(mutations, "mutation", insertArrGenerated.name, {
7224
7285
  type: arrTableItemOutput,
7225
7286
  args: insertArrGenerated.args,
7226
7287
  resolve: insertArrGenerated.resolver,
@@ -7230,8 +7291,8 @@ const createSchemaDataGenerator = (adapter) => {
7230
7291
  single: false,
7231
7292
  targetArg: "values"
7232
7293
  }) }
7233
- };
7234
- if (insertSingleGenerated) mutations[insertSingleGenerated.name] = {
7294
+ });
7295
+ if (insertSingleGenerated) defineRootField(mutations, "mutation", insertSingleGenerated.name, {
7235
7296
  type: conflictDoNothing ? singleTableItemOutput : new graphql.GraphQLNonNull(singleTableItemOutput),
7236
7297
  args: insertSingleGenerated.args,
7237
7298
  resolve: insertSingleGenerated.resolver,
@@ -7241,8 +7302,8 @@ const createSchemaDataGenerator = (adapter) => {
7241
7302
  single: true,
7242
7303
  targetArg: "values"
7243
7304
  }) }
7244
- };
7245
- if (upsertArrGenerated) mutations[upsertArrGenerated.name] = {
7305
+ });
7306
+ if (upsertArrGenerated) defineRootField(mutations, "mutation", upsertArrGenerated.name, {
7246
7307
  type: arrTableItemOutput,
7247
7308
  args: upsertArrGenerated.args,
7248
7309
  resolve: upsertArrGenerated.resolver,
@@ -7252,8 +7313,8 @@ const createSchemaDataGenerator = (adapter) => {
7252
7313
  single: false,
7253
7314
  targetArg: "values"
7254
7315
  }) }
7255
- };
7256
- if (upsertSingleGenerated) mutations[upsertSingleGenerated.name] = {
7316
+ });
7317
+ if (upsertSingleGenerated) defineRootField(mutations, "mutation", upsertSingleGenerated.name, {
7257
7318
  type: singleTableItemOutput,
7258
7319
  args: upsertSingleGenerated.args,
7259
7320
  resolve: upsertSingleGenerated.resolver,
@@ -7263,8 +7324,8 @@ const createSchemaDataGenerator = (adapter) => {
7263
7324
  single: true,
7264
7325
  targetArg: "values"
7265
7326
  }) }
7266
- };
7267
- if (updateGenerated) mutations[updateGenerated.name] = {
7327
+ });
7328
+ if (updateGenerated) defineRootField(mutations, "mutation", updateGenerated.name, {
7268
7329
  type: arrTableItemOutput,
7269
7330
  args: updateGenerated.args,
7270
7331
  resolve: updateGenerated.resolver,
@@ -7274,8 +7335,8 @@ const createSchemaDataGenerator = (adapter) => {
7274
7335
  single: false,
7275
7336
  targetArg: "where"
7276
7337
  }) }
7277
- };
7278
- if (updateManyGenerated) mutations[updateManyGenerated.name] = {
7338
+ });
7339
+ if (updateManyGenerated) defineRootField(mutations, "mutation", updateManyGenerated.name, {
7279
7340
  type: new graphql.GraphQLNonNull(new graphql.GraphQLList(singleTableItemOutput)),
7280
7341
  args: updateManyGenerated.args,
7281
7342
  resolve: updateManyGenerated.resolver,
@@ -7286,8 +7347,8 @@ const createSchemaDataGenerator = (adapter) => {
7286
7347
  targetArg: "updates"
7287
7348
  }) },
7288
7349
  description: "Each entry's updated rows, in entry order. An entry whose `where` matched no rows contributes `null` in its slot; an entry that matched several contributes each of its rows."
7289
- };
7290
- if (updateSingleGenerated) mutations[updateSingleGenerated.name] = {
7350
+ });
7351
+ if (updateSingleGenerated) defineRootField(mutations, "mutation", updateSingleGenerated.name, {
7291
7352
  type: singleTableItemOutput,
7292
7353
  args: updateSingleGenerated.args,
7293
7354
  resolve: updateSingleGenerated.resolver,
@@ -7297,8 +7358,8 @@ const createSchemaDataGenerator = (adapter) => {
7297
7358
  single: true,
7298
7359
  targetArg: "where"
7299
7360
  }) }
7300
- };
7301
- if (deleteGenerated) mutations[deleteGenerated.name] = {
7361
+ });
7362
+ if (deleteGenerated) defineRootField(mutations, "mutation", deleteGenerated.name, {
7302
7363
  type: arrTableItemOutput,
7303
7364
  args: deleteGenerated.args,
7304
7365
  resolve: deleteGenerated.resolver,
@@ -7309,8 +7370,8 @@ const createSchemaDataGenerator = (adapter) => {
7309
7370
  targetArg: "where",
7310
7371
  ...softDeleteInfo?.hardDelete ? { hardDelete: true } : {}
7311
7372
  }) }
7312
- };
7313
- if (deleteSingleGenerated) mutations[deleteSingleGenerated.name] = {
7373
+ });
7374
+ if (deleteSingleGenerated) defineRootField(mutations, "mutation", deleteSingleGenerated.name, {
7314
7375
  type: singleTableItemOutput,
7315
7376
  args: deleteSingleGenerated.args,
7316
7377
  resolve: deleteSingleGenerated.resolver,
@@ -7321,8 +7382,8 @@ const createSchemaDataGenerator = (adapter) => {
7321
7382
  targetArg: "where",
7322
7383
  ...softDeleteInfo?.hardDelete ? { hardDelete: true } : {}
7323
7384
  }) }
7324
- };
7325
- if (restoreGenerated) mutations[restoreGenerated.name] = {
7385
+ });
7386
+ if (restoreGenerated) defineRootField(mutations, "mutation", restoreGenerated.name, {
7326
7387
  type: arrTableItemOutput,
7327
7388
  args: restoreGenerated.args,
7328
7389
  resolve: restoreGenerated.resolver,
@@ -7332,8 +7393,8 @@ const createSchemaDataGenerator = (adapter) => {
7332
7393
  single: false,
7333
7394
  targetArg: "where"
7334
7395
  }) }
7335
- };
7336
- if (restoreSingleGenerated) mutations[restoreSingleGenerated.name] = {
7396
+ });
7397
+ if (restoreSingleGenerated) defineRootField(mutations, "mutation", restoreSingleGenerated.name, {
7337
7398
  type: singleTableItemOutput,
7338
7399
  args: restoreSingleGenerated.args,
7339
7400
  resolve: restoreSingleGenerated.resolver,
@@ -7343,19 +7404,19 @@ const createSchemaDataGenerator = (adapter) => {
7343
7404
  single: true,
7344
7405
  targetArg: "where"
7345
7406
  }) }
7346
- };
7347
- if (updateCountGenerated) mutations[updateCountGenerated.name] = {
7407
+ });
7408
+ if (updateCountGenerated) defineRootField(mutations, "mutation", updateCountGenerated.name, {
7348
7409
  type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
7349
7410
  args: updateCountGenerated.args,
7350
7411
  resolve: updateCountGenerated.resolver,
7351
7412
  description: "How many rows the update touched. The rows themselves are not read back, which is the point of this mutation."
7352
- };
7353
- if (deleteCountGenerated) mutations[deleteCountGenerated.name] = {
7413
+ });
7414
+ if (deleteCountGenerated) defineRootField(mutations, "mutation", deleteCountGenerated.name, {
7354
7415
  type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
7355
7416
  args: deleteCountGenerated.args,
7356
7417
  resolve: deleteCountGenerated.resolver,
7357
7418
  description: "How many rows the delete removed. The rows themselves are not read back, which is the point of this mutation."
7358
- };
7419
+ });
7359
7420
  [
7360
7421
  ...tableFeatures.insert || onConflictInput ? [insertInput] : [],
7361
7422
  ...onConflictInput ? [onConflictInput] : [],