@vantreeseba/drizzle-graphql 10.0.3 → 11.0.1
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 +15 -1
- package/dist/index.cjs +147 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +147 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
if (
|
|
3839
|
-
|
|
3840
|
-
if (
|
|
3841
|
-
|
|
3842
|
-
if (
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
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
|
|
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}${
|
|
3971
|
+
const upsertArrayFieldName = `${upsertPrefix}${pluralNoun}${suffixes.list}`;
|
|
3933
3972
|
const upsertSingleFieldName = mapped ? `${upsertPrefix}${capitalize(mapped.singular)}` : `${upsertPrefix}${capitalize(tableName)}${suffixes.single}`;
|
|
3934
|
-
const
|
|
3935
|
-
const
|
|
3936
|
-
const
|
|
3937
|
-
const
|
|
3938
|
-
const
|
|
3939
|
-
const
|
|
3940
|
-
const
|
|
3941
|
-
const
|
|
3942
|
-
const
|
|
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*`
|
|
@@ -5303,17 +5364,22 @@ const createRelationAggregateFactory = (db, tables, cacheCtx, typeNameMapper, fi
|
|
|
5303
5364
|
};
|
|
5304
5365
|
const resolve = async (parent, args, context, info) => {
|
|
5305
5366
|
try {
|
|
5306
|
-
const request =
|
|
5367
|
+
const { request, loaderKey } = getOrCreateRequestValue(context, info?.fieldNodes?.[0], `aggregate:${tableName}::${relationName}`, () => {
|
|
5368
|
+
const request = parseAggregateRequest(info, target);
|
|
5369
|
+
return {
|
|
5370
|
+
request,
|
|
5371
|
+
loaderKey: `${tableName}::${relationName}::aggregate::${JSON.stringify({
|
|
5372
|
+
where: args?.where ?? null,
|
|
5373
|
+
deleted: args?.deleted ?? defaultDeleted ?? null,
|
|
5374
|
+
selection: Object.keys(request.selection).sort()
|
|
5375
|
+
})}`
|
|
5376
|
+
};
|
|
5377
|
+
});
|
|
5307
5378
|
if (!Object.keys(request.selection).length) return {};
|
|
5308
5379
|
const localValue = parent[localColPropName];
|
|
5309
5380
|
if (localValue == null) return assembleAggregateRow({}, request, target);
|
|
5310
5381
|
const whereArg = args?.where;
|
|
5311
5382
|
const deleted = args?.deleted;
|
|
5312
|
-
const loaderKey = `${tableName}::${relationName}::aggregate::${JSON.stringify({
|
|
5313
|
-
where: whereArg ?? null,
|
|
5314
|
-
deleted: deleted ?? defaultDeleted ?? null,
|
|
5315
|
-
selection: Object.keys(request.selection).sort()
|
|
5316
|
-
})}`;
|
|
5317
5383
|
const loader = getOrCreateLoader(context, loaderKey, async (parentIds) => {
|
|
5318
5384
|
const executor = resolveExecutor(db, context);
|
|
5319
5385
|
const uniqueIds = [...new Set(parentIds)];
|
|
@@ -6324,7 +6390,7 @@ const createSchemaBuilder = (adapter) => {
|
|
|
6324
6390
|
const groupByEnum = groupByType ? generateGroupByEnum(table, tableName, typeName, cacheCtx) : void 0;
|
|
6325
6391
|
const havingInput = groupByEnum ? generateHavingInput(table, tableName, typeName, cacheCtx) : void 0;
|
|
6326
6392
|
const groupByGenerated = groupByType && groupByEnum && havingInput ? generateGroupBy(db, tableName, table, typeName, groupByFieldName, tableFilters, groupByEnum, havingInput, filterCtx, tablePolicies, cacheCtx.typeName) : void 0;
|
|
6327
|
-
ctx.queries
|
|
6393
|
+
defineRootField(ctx.queries, "query", selectArrGenerated.name, {
|
|
6328
6394
|
type: selectArrOutput,
|
|
6329
6395
|
args: selectArrGenerated.args,
|
|
6330
6396
|
resolve: selectArrGenerated.resolver,
|
|
@@ -6337,8 +6403,8 @@ const createSchemaBuilder = (adapter) => {
|
|
|
6337
6403
|
}),
|
|
6338
6404
|
...complexity ? { complexity: listFieldComplexity(complexity, limits?.(tableName)) } : {}
|
|
6339
6405
|
}
|
|
6340
|
-
};
|
|
6341
|
-
ctx.queries
|
|
6406
|
+
});
|
|
6407
|
+
defineRootField(ctx.queries, "query", selectSingleGenerated.name, {
|
|
6342
6408
|
type: selectSingleOutput,
|
|
6343
6409
|
args: selectSingleGenerated.args,
|
|
6344
6410
|
resolve: selectSingleGenerated.resolver,
|
|
@@ -6348,8 +6414,8 @@ const createSchemaBuilder = (adapter) => {
|
|
|
6348
6414
|
single: true,
|
|
6349
6415
|
targetArg: "where"
|
|
6350
6416
|
}) }
|
|
6351
|
-
};
|
|
6352
|
-
if (aggregateGenerated && aggregateType) ctx.queries
|
|
6417
|
+
});
|
|
6418
|
+
if (aggregateGenerated && aggregateType) defineRootField(ctx.queries, "query", aggregateGenerated.name, {
|
|
6353
6419
|
type: new graphql.GraphQLNonNull(aggregateType),
|
|
6354
6420
|
args: aggregateGenerated.args,
|
|
6355
6421
|
resolve: aggregateGenerated.resolver,
|
|
@@ -6362,8 +6428,8 @@ const createSchemaBuilder = (adapter) => {
|
|
|
6362
6428
|
}),
|
|
6363
6429
|
...complexity ? { complexity: aggregateFieldComplexity(complexity) } : {}
|
|
6364
6430
|
}
|
|
6365
|
-
};
|
|
6366
|
-
if (groupByGenerated && groupByType) ctx.queries
|
|
6431
|
+
});
|
|
6432
|
+
if (groupByGenerated && groupByType) defineRootField(ctx.queries, "query", groupByGenerated.name, {
|
|
6367
6433
|
type: new graphql.GraphQLNonNull(new graphql.GraphQLList(new graphql.GraphQLNonNull(groupByType))),
|
|
6368
6434
|
args: groupByGenerated.args,
|
|
6369
6435
|
resolve: groupByGenerated.resolver,
|
|
@@ -6376,7 +6442,7 @@ const createSchemaBuilder = (adapter) => {
|
|
|
6376
6442
|
}),
|
|
6377
6443
|
...complexity ? { complexity: aggregateFieldComplexity(complexity) } : {}
|
|
6378
6444
|
}
|
|
6379
|
-
};
|
|
6445
|
+
});
|
|
6380
6446
|
return {
|
|
6381
6447
|
aggregateType,
|
|
6382
6448
|
groupByType,
|
|
@@ -6754,7 +6820,7 @@ const generateSchemaData$2 = (db, schema, relations, options) => {
|
|
|
6754
6820
|
targetArg: "where"
|
|
6755
6821
|
}]
|
|
6756
6822
|
];
|
|
6757
|
-
for (const [generated, meta] of generatedMutations) if (generated) mutations
|
|
6823
|
+
for (const [generated, meta] of generatedMutations) if (generated) defineRootField(mutations, "mutation", generated.name, {
|
|
6758
6824
|
type: mutationReturnType,
|
|
6759
6825
|
args: generated.args,
|
|
6760
6826
|
resolve: generated.resolver,
|
|
@@ -6762,19 +6828,19 @@ const generateSchemaData$2 = (db, schema, relations, options) => {
|
|
|
6762
6828
|
kind: "mutation",
|
|
6763
6829
|
...meta
|
|
6764
6830
|
}) }
|
|
6765
|
-
};
|
|
6766
|
-
if (updateCountGenerated) mutations
|
|
6831
|
+
});
|
|
6832
|
+
if (updateCountGenerated) defineRootField(mutations, "mutation", updateCountGenerated.name, {
|
|
6767
6833
|
type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
|
|
6768
6834
|
args: updateCountGenerated.args,
|
|
6769
6835
|
resolve: updateCountGenerated.resolver,
|
|
6770
6836
|
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
|
|
6837
|
+
});
|
|
6838
|
+
if (deleteCountGenerated) defineRootField(mutations, "mutation", deleteCountGenerated.name, {
|
|
6773
6839
|
type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
|
|
6774
6840
|
args: deleteCountGenerated.args,
|
|
6775
6841
|
resolve: deleteCountGenerated.resolver,
|
|
6776
6842
|
description: "How many rows the delete removed. The rows themselves are not read back, which is the point of this mutation."
|
|
6777
|
-
};
|
|
6843
|
+
});
|
|
6778
6844
|
[
|
|
6779
6845
|
...tableFeatures.insert || onConflictInput ? [insertInput] : [],
|
|
6780
6846
|
...onConflictInput ? [onConflictInput] : [],
|
|
@@ -7220,7 +7286,7 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7220
7286
|
filterCtx,
|
|
7221
7287
|
txCtx: mutationTxCtx
|
|
7222
7288
|
}) : void 0;
|
|
7223
|
-
if (insertArrGenerated) mutations
|
|
7289
|
+
if (insertArrGenerated) defineRootField(mutations, "mutation", insertArrGenerated.name, {
|
|
7224
7290
|
type: arrTableItemOutput,
|
|
7225
7291
|
args: insertArrGenerated.args,
|
|
7226
7292
|
resolve: insertArrGenerated.resolver,
|
|
@@ -7230,8 +7296,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7230
7296
|
single: false,
|
|
7231
7297
|
targetArg: "values"
|
|
7232
7298
|
}) }
|
|
7233
|
-
};
|
|
7234
|
-
if (insertSingleGenerated) mutations
|
|
7299
|
+
});
|
|
7300
|
+
if (insertSingleGenerated) defineRootField(mutations, "mutation", insertSingleGenerated.name, {
|
|
7235
7301
|
type: conflictDoNothing ? singleTableItemOutput : new graphql.GraphQLNonNull(singleTableItemOutput),
|
|
7236
7302
|
args: insertSingleGenerated.args,
|
|
7237
7303
|
resolve: insertSingleGenerated.resolver,
|
|
@@ -7241,8 +7307,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7241
7307
|
single: true,
|
|
7242
7308
|
targetArg: "values"
|
|
7243
7309
|
}) }
|
|
7244
|
-
};
|
|
7245
|
-
if (upsertArrGenerated) mutations
|
|
7310
|
+
});
|
|
7311
|
+
if (upsertArrGenerated) defineRootField(mutations, "mutation", upsertArrGenerated.name, {
|
|
7246
7312
|
type: arrTableItemOutput,
|
|
7247
7313
|
args: upsertArrGenerated.args,
|
|
7248
7314
|
resolve: upsertArrGenerated.resolver,
|
|
@@ -7252,8 +7318,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7252
7318
|
single: false,
|
|
7253
7319
|
targetArg: "values"
|
|
7254
7320
|
}) }
|
|
7255
|
-
};
|
|
7256
|
-
if (upsertSingleGenerated) mutations
|
|
7321
|
+
});
|
|
7322
|
+
if (upsertSingleGenerated) defineRootField(mutations, "mutation", upsertSingleGenerated.name, {
|
|
7257
7323
|
type: singleTableItemOutput,
|
|
7258
7324
|
args: upsertSingleGenerated.args,
|
|
7259
7325
|
resolve: upsertSingleGenerated.resolver,
|
|
@@ -7263,8 +7329,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7263
7329
|
single: true,
|
|
7264
7330
|
targetArg: "values"
|
|
7265
7331
|
}) }
|
|
7266
|
-
};
|
|
7267
|
-
if (updateGenerated) mutations
|
|
7332
|
+
});
|
|
7333
|
+
if (updateGenerated) defineRootField(mutations, "mutation", updateGenerated.name, {
|
|
7268
7334
|
type: arrTableItemOutput,
|
|
7269
7335
|
args: updateGenerated.args,
|
|
7270
7336
|
resolve: updateGenerated.resolver,
|
|
@@ -7274,8 +7340,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7274
7340
|
single: false,
|
|
7275
7341
|
targetArg: "where"
|
|
7276
7342
|
}) }
|
|
7277
|
-
};
|
|
7278
|
-
if (updateManyGenerated) mutations
|
|
7343
|
+
});
|
|
7344
|
+
if (updateManyGenerated) defineRootField(mutations, "mutation", updateManyGenerated.name, {
|
|
7279
7345
|
type: new graphql.GraphQLNonNull(new graphql.GraphQLList(singleTableItemOutput)),
|
|
7280
7346
|
args: updateManyGenerated.args,
|
|
7281
7347
|
resolve: updateManyGenerated.resolver,
|
|
@@ -7286,8 +7352,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7286
7352
|
targetArg: "updates"
|
|
7287
7353
|
}) },
|
|
7288
7354
|
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
|
|
7355
|
+
});
|
|
7356
|
+
if (updateSingleGenerated) defineRootField(mutations, "mutation", updateSingleGenerated.name, {
|
|
7291
7357
|
type: singleTableItemOutput,
|
|
7292
7358
|
args: updateSingleGenerated.args,
|
|
7293
7359
|
resolve: updateSingleGenerated.resolver,
|
|
@@ -7297,8 +7363,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7297
7363
|
single: true,
|
|
7298
7364
|
targetArg: "where"
|
|
7299
7365
|
}) }
|
|
7300
|
-
};
|
|
7301
|
-
if (deleteGenerated) mutations
|
|
7366
|
+
});
|
|
7367
|
+
if (deleteGenerated) defineRootField(mutations, "mutation", deleteGenerated.name, {
|
|
7302
7368
|
type: arrTableItemOutput,
|
|
7303
7369
|
args: deleteGenerated.args,
|
|
7304
7370
|
resolve: deleteGenerated.resolver,
|
|
@@ -7309,8 +7375,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7309
7375
|
targetArg: "where",
|
|
7310
7376
|
...softDeleteInfo?.hardDelete ? { hardDelete: true } : {}
|
|
7311
7377
|
}) }
|
|
7312
|
-
};
|
|
7313
|
-
if (deleteSingleGenerated) mutations
|
|
7378
|
+
});
|
|
7379
|
+
if (deleteSingleGenerated) defineRootField(mutations, "mutation", deleteSingleGenerated.name, {
|
|
7314
7380
|
type: singleTableItemOutput,
|
|
7315
7381
|
args: deleteSingleGenerated.args,
|
|
7316
7382
|
resolve: deleteSingleGenerated.resolver,
|
|
@@ -7321,8 +7387,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7321
7387
|
targetArg: "where",
|
|
7322
7388
|
...softDeleteInfo?.hardDelete ? { hardDelete: true } : {}
|
|
7323
7389
|
}) }
|
|
7324
|
-
};
|
|
7325
|
-
if (restoreGenerated) mutations
|
|
7390
|
+
});
|
|
7391
|
+
if (restoreGenerated) defineRootField(mutations, "mutation", restoreGenerated.name, {
|
|
7326
7392
|
type: arrTableItemOutput,
|
|
7327
7393
|
args: restoreGenerated.args,
|
|
7328
7394
|
resolve: restoreGenerated.resolver,
|
|
@@ -7332,8 +7398,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7332
7398
|
single: false,
|
|
7333
7399
|
targetArg: "where"
|
|
7334
7400
|
}) }
|
|
7335
|
-
};
|
|
7336
|
-
if (restoreSingleGenerated) mutations
|
|
7401
|
+
});
|
|
7402
|
+
if (restoreSingleGenerated) defineRootField(mutations, "mutation", restoreSingleGenerated.name, {
|
|
7337
7403
|
type: singleTableItemOutput,
|
|
7338
7404
|
args: restoreSingleGenerated.args,
|
|
7339
7405
|
resolve: restoreSingleGenerated.resolver,
|
|
@@ -7343,19 +7409,19 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7343
7409
|
single: true,
|
|
7344
7410
|
targetArg: "where"
|
|
7345
7411
|
}) }
|
|
7346
|
-
};
|
|
7347
|
-
if (updateCountGenerated) mutations
|
|
7412
|
+
});
|
|
7413
|
+
if (updateCountGenerated) defineRootField(mutations, "mutation", updateCountGenerated.name, {
|
|
7348
7414
|
type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
|
|
7349
7415
|
args: updateCountGenerated.args,
|
|
7350
7416
|
resolve: updateCountGenerated.resolver,
|
|
7351
7417
|
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
|
|
7418
|
+
});
|
|
7419
|
+
if (deleteCountGenerated) defineRootField(mutations, "mutation", deleteCountGenerated.name, {
|
|
7354
7420
|
type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
|
|
7355
7421
|
args: deleteCountGenerated.args,
|
|
7356
7422
|
resolve: deleteCountGenerated.resolver,
|
|
7357
7423
|
description: "How many rows the delete removed. The rows themselves are not read back, which is the point of this mutation."
|
|
7358
|
-
};
|
|
7424
|
+
});
|
|
7359
7425
|
[
|
|
7360
7426
|
...tableFeatures.insert || onConflictInput ? [insertInput] : [],
|
|
7361
7427
|
...onConflictInput ? [onConflictInput] : [],
|