@vantreeseba/drizzle-graphql 10.0.2 → 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 +15 -1
- package/dist/index.cjs +150 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +150 -83
- 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
|
@@ -3178,16 +3178,23 @@ const extractRelationsParams = (relationMap, tables, tableName, info, typeName,
|
|
|
3178
3178
|
if (!info) return;
|
|
3179
3179
|
const relationsForTable = relationMap[tableName];
|
|
3180
3180
|
if (!relationsForTable) return;
|
|
3181
|
-
const baseField =
|
|
3181
|
+
const baseField = info.fieldsByTypeName[typeName];
|
|
3182
3182
|
if (!baseField) return;
|
|
3183
|
+
const selectionsByName = /* @__PURE__ */ new Map();
|
|
3184
|
+
for (const selection of Object.values(baseField)) {
|
|
3185
|
+
const selections = selectionsByName.get(selection.name);
|
|
3186
|
+
if (selections) selections.push(selection);
|
|
3187
|
+
else selectionsByName.set(selection.name, [selection]);
|
|
3188
|
+
}
|
|
3183
3189
|
const args = {};
|
|
3184
3190
|
for (const [relName, relEntry] of Object.entries(relationsForTable)) {
|
|
3185
3191
|
const { targetTableName, targetPkNames } = relEntry;
|
|
3186
3192
|
const relTypeName = resolveObjectTypeName(targetTableName, typeNameMapper, resolveName);
|
|
3187
|
-
const
|
|
3188
|
-
if (!
|
|
3189
|
-
|
|
3190
|
-
|
|
3193
|
+
const selections = selectionsByName.get(relName);
|
|
3194
|
+
if (!selections) continue;
|
|
3195
|
+
const field = selections[0];
|
|
3196
|
+
if (selections.length > 1) continue;
|
|
3197
|
+
const relFieldSelection = field.fieldsByTypeName[relTypeName];
|
|
3191
3198
|
if (!relFieldSelection) continue;
|
|
3192
3199
|
const eagerArgs = field.args;
|
|
3193
3200
|
if (!(0, drizzle_orm.is)(relEntry.relation ?? relEntry, drizzle_orm.One) && (eagerArgs?.after != null || !!(eagerArgs?.distinct)?.length || isCursorFieldSelected(relFieldSelection, tables[targetTableName]))) continue;
|
|
@@ -3199,8 +3206,7 @@ const extractRelationsParams = (relationMap, tables, tableName, info, typeName,
|
|
|
3199
3206
|
});
|
|
3200
3207
|
const thisRecord = {};
|
|
3201
3208
|
thisRecord.columns = columns;
|
|
3202
|
-
const
|
|
3203
|
-
const relationArgs = (0, drizzle_orm.is)(relEntry.relation, drizzle_orm.One) ? relationField?.args : relationField && withDefaultOrderBy(relationField.args ?? {}, targetTableName, defaultOrderBy);
|
|
3209
|
+
const relationArgs = (0, drizzle_orm.is)(relEntry.relation, drizzle_orm.One) ? field.args : withDefaultOrderBy(field.args ?? {}, targetTableName, defaultOrderBy);
|
|
3204
3210
|
const offset = relationArgs?.offset ?? void 0;
|
|
3205
3211
|
const limit = (0, drizzle_orm.is)(relEntry.relation, drizzle_orm.One) ? relationArgs?.limit ?? void 0 : applyLimitPolicy(relationArgs?.limit, limits?.(targetTableName), {
|
|
3206
3212
|
table: targetTableName,
|
|
@@ -3215,7 +3221,7 @@ const extractRelationsParams = (relationMap, tables, tableName, info, typeName,
|
|
|
3215
3221
|
thisRecord.orderBy = relationArgs?.orderBy ? (aliasedTable) => extractOrderBy(aliasedTable, relationArgs.orderBy, relationFilterCtx(filterCtx, targetTableName), relWhere) : hasPagination && pkNames.length ? (aliasedTable) => primaryKeyOrderExprs(aliasedTable, pkNames) : void 0;
|
|
3216
3222
|
thisRecord.offset = offset;
|
|
3217
3223
|
thisRecord.limit = limit;
|
|
3218
|
-
thisRecord.with = extractRelationsParams(relationMap, tables, targetTableName,
|
|
3224
|
+
thisRecord.with = extractRelationsParams(relationMap, tables, targetTableName, field, relTypeName, options);
|
|
3219
3225
|
args[relName] = thisRecord;
|
|
3220
3226
|
}
|
|
3221
3227
|
return args;
|
|
@@ -3563,6 +3569,7 @@ const generateWriteCount = ({ db, tableName, table, kind, setArgs, filterArgs, f
|
|
|
3563
3569
|
//#endregion
|
|
3564
3570
|
//#region src/util/batch-loader/index.ts
|
|
3565
3571
|
const DRIZZLE_LOADERS_KEY = Symbol("drizzle-graphql-loaders");
|
|
3572
|
+
const DRIZZLE_REQUEST_CACHE_KEY = Symbol("drizzle-graphql-request-cache");
|
|
3566
3573
|
var BatchLoader = class {
|
|
3567
3574
|
batchFn;
|
|
3568
3575
|
batch = [];
|
|
@@ -3606,6 +3613,32 @@ const getOrCreateLoader = (context, key, batchFn) => {
|
|
|
3606
3613
|
if (!loaders.has(key)) loaders.set(key, new BatchLoader(batchFn));
|
|
3607
3614
|
return loaders.get(key);
|
|
3608
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
|
+
};
|
|
3609
3642
|
//#endregion
|
|
3610
3643
|
//#region src/util/extensions.ts
|
|
3611
3644
|
/**
|
|
@@ -3823,30 +3856,40 @@ const createRelationResolverFactory = (db, tables, nullOrdering, filterCtx, limi
|
|
|
3823
3856
|
const localValue = parent[localColPropName];
|
|
3824
3857
|
if (localValue == null) return isOne ? null : [];
|
|
3825
3858
|
const { where: whereArg, limit: requestedLimit, offset, after, deleted } = args ?? {};
|
|
3826
|
-
const orderByArg
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
if (
|
|
3833
|
-
|
|
3834
|
-
if (
|
|
3835
|
-
|
|
3836
|
-
if (
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
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
|
+
});
|
|
3850
3893
|
return getOrCreateLoader(context, loaderKey, async (parentIds) => {
|
|
3851
3894
|
const executor = resolveExecutor(db, context);
|
|
3852
3895
|
const uniqueIds = [...new Set(parentIds)];
|
|
@@ -3920,20 +3963,24 @@ const computeResolverFieldNames = (tableName, typeNameMapper, prefixes, suffixes
|
|
|
3920
3963
|
const singleFieldName = mapped?.singular ?? uncapitalize(tableName) + suffixes.single;
|
|
3921
3964
|
const aggregateFieldName = `${mapped?.plural ?? uncapitalize(tableName)}Aggregate`;
|
|
3922
3965
|
const groupByFieldName = `${mapped?.plural ?? uncapitalize(tableName)}GroupBy`;
|
|
3923
|
-
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}`;
|
|
3924
3969
|
const createSingleFieldName = mapped ? `${prefixes.insert}${capitalize(mapped.singular)}` : `${prefixes.insert}${capitalize(tableName)}${suffixes.single}`;
|
|
3925
3970
|
const upsertPrefix = prefixes.upsert ?? "upsert";
|
|
3926
|
-
const upsertArrayFieldName = `${upsertPrefix}${
|
|
3971
|
+
const upsertArrayFieldName = `${upsertPrefix}${pluralNoun}${suffixes.list}`;
|
|
3927
3972
|
const upsertSingleFieldName = mapped ? `${upsertPrefix}${capitalize(mapped.singular)}` : `${upsertPrefix}${capitalize(tableName)}${suffixes.single}`;
|
|
3928
|
-
const
|
|
3929
|
-
const
|
|
3930
|
-
const
|
|
3931
|
-
const
|
|
3932
|
-
const
|
|
3933
|
-
const
|
|
3934
|
-
const
|
|
3935
|
-
const
|
|
3936
|
-
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}`;
|
|
3937
3984
|
return {
|
|
3938
3985
|
typeName,
|
|
3939
3986
|
listFieldName,
|
|
@@ -3956,6 +4003,26 @@ const computeResolverFieldNames = (tableName, typeNameMapper, prefixes, suffixes
|
|
|
3956
4003
|
};
|
|
3957
4004
|
};
|
|
3958
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
|
|
3959
4026
|
//#region src/util/builders/common/select-runtime.ts
|
|
3960
4027
|
/**
|
|
3961
4028
|
* Runs the relational-query-builder select shared by every dialect's `generateSelect*`
|
|
@@ -6318,7 +6385,7 @@ const createSchemaBuilder = (adapter) => {
|
|
|
6318
6385
|
const groupByEnum = groupByType ? generateGroupByEnum(table, tableName, typeName, cacheCtx) : void 0;
|
|
6319
6386
|
const havingInput = groupByEnum ? generateHavingInput(table, tableName, typeName, cacheCtx) : void 0;
|
|
6320
6387
|
const groupByGenerated = groupByType && groupByEnum && havingInput ? generateGroupBy(db, tableName, table, typeName, groupByFieldName, tableFilters, groupByEnum, havingInput, filterCtx, tablePolicies, cacheCtx.typeName) : void 0;
|
|
6321
|
-
ctx.queries
|
|
6388
|
+
defineRootField(ctx.queries, "query", selectArrGenerated.name, {
|
|
6322
6389
|
type: selectArrOutput,
|
|
6323
6390
|
args: selectArrGenerated.args,
|
|
6324
6391
|
resolve: selectArrGenerated.resolver,
|
|
@@ -6331,8 +6398,8 @@ const createSchemaBuilder = (adapter) => {
|
|
|
6331
6398
|
}),
|
|
6332
6399
|
...complexity ? { complexity: listFieldComplexity(complexity, limits?.(tableName)) } : {}
|
|
6333
6400
|
}
|
|
6334
|
-
};
|
|
6335
|
-
ctx.queries
|
|
6401
|
+
});
|
|
6402
|
+
defineRootField(ctx.queries, "query", selectSingleGenerated.name, {
|
|
6336
6403
|
type: selectSingleOutput,
|
|
6337
6404
|
args: selectSingleGenerated.args,
|
|
6338
6405
|
resolve: selectSingleGenerated.resolver,
|
|
@@ -6342,8 +6409,8 @@ const createSchemaBuilder = (adapter) => {
|
|
|
6342
6409
|
single: true,
|
|
6343
6410
|
targetArg: "where"
|
|
6344
6411
|
}) }
|
|
6345
|
-
};
|
|
6346
|
-
if (aggregateGenerated && aggregateType) ctx.queries
|
|
6412
|
+
});
|
|
6413
|
+
if (aggregateGenerated && aggregateType) defineRootField(ctx.queries, "query", aggregateGenerated.name, {
|
|
6347
6414
|
type: new graphql.GraphQLNonNull(aggregateType),
|
|
6348
6415
|
args: aggregateGenerated.args,
|
|
6349
6416
|
resolve: aggregateGenerated.resolver,
|
|
@@ -6356,8 +6423,8 @@ const createSchemaBuilder = (adapter) => {
|
|
|
6356
6423
|
}),
|
|
6357
6424
|
...complexity ? { complexity: aggregateFieldComplexity(complexity) } : {}
|
|
6358
6425
|
}
|
|
6359
|
-
};
|
|
6360
|
-
if (groupByGenerated && groupByType) ctx.queries
|
|
6426
|
+
});
|
|
6427
|
+
if (groupByGenerated && groupByType) defineRootField(ctx.queries, "query", groupByGenerated.name, {
|
|
6361
6428
|
type: new graphql.GraphQLNonNull(new graphql.GraphQLList(new graphql.GraphQLNonNull(groupByType))),
|
|
6362
6429
|
args: groupByGenerated.args,
|
|
6363
6430
|
resolve: groupByGenerated.resolver,
|
|
@@ -6370,7 +6437,7 @@ const createSchemaBuilder = (adapter) => {
|
|
|
6370
6437
|
}),
|
|
6371
6438
|
...complexity ? { complexity: aggregateFieldComplexity(complexity) } : {}
|
|
6372
6439
|
}
|
|
6373
|
-
};
|
|
6440
|
+
});
|
|
6374
6441
|
return {
|
|
6375
6442
|
aggregateType,
|
|
6376
6443
|
groupByType,
|
|
@@ -6748,7 +6815,7 @@ const generateSchemaData$2 = (db, schema, relations, options) => {
|
|
|
6748
6815
|
targetArg: "where"
|
|
6749
6816
|
}]
|
|
6750
6817
|
];
|
|
6751
|
-
for (const [generated, meta] of generatedMutations) if (generated) mutations
|
|
6818
|
+
for (const [generated, meta] of generatedMutations) if (generated) defineRootField(mutations, "mutation", generated.name, {
|
|
6752
6819
|
type: mutationReturnType,
|
|
6753
6820
|
args: generated.args,
|
|
6754
6821
|
resolve: generated.resolver,
|
|
@@ -6756,19 +6823,19 @@ const generateSchemaData$2 = (db, schema, relations, options) => {
|
|
|
6756
6823
|
kind: "mutation",
|
|
6757
6824
|
...meta
|
|
6758
6825
|
}) }
|
|
6759
|
-
};
|
|
6760
|
-
if (updateCountGenerated) mutations
|
|
6826
|
+
});
|
|
6827
|
+
if (updateCountGenerated) defineRootField(mutations, "mutation", updateCountGenerated.name, {
|
|
6761
6828
|
type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
|
|
6762
6829
|
args: updateCountGenerated.args,
|
|
6763
6830
|
resolve: updateCountGenerated.resolver,
|
|
6764
6831
|
description: "How many rows the update touched. The rows themselves are not read back, which is the point of this mutation."
|
|
6765
|
-
};
|
|
6766
|
-
if (deleteCountGenerated) mutations
|
|
6832
|
+
});
|
|
6833
|
+
if (deleteCountGenerated) defineRootField(mutations, "mutation", deleteCountGenerated.name, {
|
|
6767
6834
|
type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
|
|
6768
6835
|
args: deleteCountGenerated.args,
|
|
6769
6836
|
resolve: deleteCountGenerated.resolver,
|
|
6770
6837
|
description: "How many rows the delete removed. The rows themselves are not read back, which is the point of this mutation."
|
|
6771
|
-
};
|
|
6838
|
+
});
|
|
6772
6839
|
[
|
|
6773
6840
|
...tableFeatures.insert || onConflictInput ? [insertInput] : [],
|
|
6774
6841
|
...onConflictInput ? [onConflictInput] : [],
|
|
@@ -7214,7 +7281,7 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7214
7281
|
filterCtx,
|
|
7215
7282
|
txCtx: mutationTxCtx
|
|
7216
7283
|
}) : void 0;
|
|
7217
|
-
if (insertArrGenerated) mutations
|
|
7284
|
+
if (insertArrGenerated) defineRootField(mutations, "mutation", insertArrGenerated.name, {
|
|
7218
7285
|
type: arrTableItemOutput,
|
|
7219
7286
|
args: insertArrGenerated.args,
|
|
7220
7287
|
resolve: insertArrGenerated.resolver,
|
|
@@ -7224,8 +7291,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7224
7291
|
single: false,
|
|
7225
7292
|
targetArg: "values"
|
|
7226
7293
|
}) }
|
|
7227
|
-
};
|
|
7228
|
-
if (insertSingleGenerated) mutations
|
|
7294
|
+
});
|
|
7295
|
+
if (insertSingleGenerated) defineRootField(mutations, "mutation", insertSingleGenerated.name, {
|
|
7229
7296
|
type: conflictDoNothing ? singleTableItemOutput : new graphql.GraphQLNonNull(singleTableItemOutput),
|
|
7230
7297
|
args: insertSingleGenerated.args,
|
|
7231
7298
|
resolve: insertSingleGenerated.resolver,
|
|
@@ -7235,8 +7302,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7235
7302
|
single: true,
|
|
7236
7303
|
targetArg: "values"
|
|
7237
7304
|
}) }
|
|
7238
|
-
};
|
|
7239
|
-
if (upsertArrGenerated) mutations
|
|
7305
|
+
});
|
|
7306
|
+
if (upsertArrGenerated) defineRootField(mutations, "mutation", upsertArrGenerated.name, {
|
|
7240
7307
|
type: arrTableItemOutput,
|
|
7241
7308
|
args: upsertArrGenerated.args,
|
|
7242
7309
|
resolve: upsertArrGenerated.resolver,
|
|
@@ -7246,8 +7313,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7246
7313
|
single: false,
|
|
7247
7314
|
targetArg: "values"
|
|
7248
7315
|
}) }
|
|
7249
|
-
};
|
|
7250
|
-
if (upsertSingleGenerated) mutations
|
|
7316
|
+
});
|
|
7317
|
+
if (upsertSingleGenerated) defineRootField(mutations, "mutation", upsertSingleGenerated.name, {
|
|
7251
7318
|
type: singleTableItemOutput,
|
|
7252
7319
|
args: upsertSingleGenerated.args,
|
|
7253
7320
|
resolve: upsertSingleGenerated.resolver,
|
|
@@ -7257,8 +7324,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7257
7324
|
single: true,
|
|
7258
7325
|
targetArg: "values"
|
|
7259
7326
|
}) }
|
|
7260
|
-
};
|
|
7261
|
-
if (updateGenerated) mutations
|
|
7327
|
+
});
|
|
7328
|
+
if (updateGenerated) defineRootField(mutations, "mutation", updateGenerated.name, {
|
|
7262
7329
|
type: arrTableItemOutput,
|
|
7263
7330
|
args: updateGenerated.args,
|
|
7264
7331
|
resolve: updateGenerated.resolver,
|
|
@@ -7268,8 +7335,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7268
7335
|
single: false,
|
|
7269
7336
|
targetArg: "where"
|
|
7270
7337
|
}) }
|
|
7271
|
-
};
|
|
7272
|
-
if (updateManyGenerated) mutations
|
|
7338
|
+
});
|
|
7339
|
+
if (updateManyGenerated) defineRootField(mutations, "mutation", updateManyGenerated.name, {
|
|
7273
7340
|
type: new graphql.GraphQLNonNull(new graphql.GraphQLList(singleTableItemOutput)),
|
|
7274
7341
|
args: updateManyGenerated.args,
|
|
7275
7342
|
resolve: updateManyGenerated.resolver,
|
|
@@ -7280,8 +7347,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7280
7347
|
targetArg: "updates"
|
|
7281
7348
|
}) },
|
|
7282
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."
|
|
7283
|
-
};
|
|
7284
|
-
if (updateSingleGenerated) mutations
|
|
7350
|
+
});
|
|
7351
|
+
if (updateSingleGenerated) defineRootField(mutations, "mutation", updateSingleGenerated.name, {
|
|
7285
7352
|
type: singleTableItemOutput,
|
|
7286
7353
|
args: updateSingleGenerated.args,
|
|
7287
7354
|
resolve: updateSingleGenerated.resolver,
|
|
@@ -7291,8 +7358,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7291
7358
|
single: true,
|
|
7292
7359
|
targetArg: "where"
|
|
7293
7360
|
}) }
|
|
7294
|
-
};
|
|
7295
|
-
if (deleteGenerated) mutations
|
|
7361
|
+
});
|
|
7362
|
+
if (deleteGenerated) defineRootField(mutations, "mutation", deleteGenerated.name, {
|
|
7296
7363
|
type: arrTableItemOutput,
|
|
7297
7364
|
args: deleteGenerated.args,
|
|
7298
7365
|
resolve: deleteGenerated.resolver,
|
|
@@ -7303,8 +7370,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7303
7370
|
targetArg: "where",
|
|
7304
7371
|
...softDeleteInfo?.hardDelete ? { hardDelete: true } : {}
|
|
7305
7372
|
}) }
|
|
7306
|
-
};
|
|
7307
|
-
if (deleteSingleGenerated) mutations
|
|
7373
|
+
});
|
|
7374
|
+
if (deleteSingleGenerated) defineRootField(mutations, "mutation", deleteSingleGenerated.name, {
|
|
7308
7375
|
type: singleTableItemOutput,
|
|
7309
7376
|
args: deleteSingleGenerated.args,
|
|
7310
7377
|
resolve: deleteSingleGenerated.resolver,
|
|
@@ -7315,8 +7382,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7315
7382
|
targetArg: "where",
|
|
7316
7383
|
...softDeleteInfo?.hardDelete ? { hardDelete: true } : {}
|
|
7317
7384
|
}) }
|
|
7318
|
-
};
|
|
7319
|
-
if (restoreGenerated) mutations
|
|
7385
|
+
});
|
|
7386
|
+
if (restoreGenerated) defineRootField(mutations, "mutation", restoreGenerated.name, {
|
|
7320
7387
|
type: arrTableItemOutput,
|
|
7321
7388
|
args: restoreGenerated.args,
|
|
7322
7389
|
resolve: restoreGenerated.resolver,
|
|
@@ -7326,8 +7393,8 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7326
7393
|
single: false,
|
|
7327
7394
|
targetArg: "where"
|
|
7328
7395
|
}) }
|
|
7329
|
-
};
|
|
7330
|
-
if (restoreSingleGenerated) mutations
|
|
7396
|
+
});
|
|
7397
|
+
if (restoreSingleGenerated) defineRootField(mutations, "mutation", restoreSingleGenerated.name, {
|
|
7331
7398
|
type: singleTableItemOutput,
|
|
7332
7399
|
args: restoreSingleGenerated.args,
|
|
7333
7400
|
resolve: restoreSingleGenerated.resolver,
|
|
@@ -7337,19 +7404,19 @@ const createSchemaDataGenerator = (adapter) => {
|
|
|
7337
7404
|
single: true,
|
|
7338
7405
|
targetArg: "where"
|
|
7339
7406
|
}) }
|
|
7340
|
-
};
|
|
7341
|
-
if (updateCountGenerated) mutations
|
|
7407
|
+
});
|
|
7408
|
+
if (updateCountGenerated) defineRootField(mutations, "mutation", updateCountGenerated.name, {
|
|
7342
7409
|
type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
|
|
7343
7410
|
args: updateCountGenerated.args,
|
|
7344
7411
|
resolve: updateCountGenerated.resolver,
|
|
7345
7412
|
description: "How many rows the update touched. The rows themselves are not read back, which is the point of this mutation."
|
|
7346
|
-
};
|
|
7347
|
-
if (deleteCountGenerated) mutations
|
|
7413
|
+
});
|
|
7414
|
+
if (deleteCountGenerated) defineRootField(mutations, "mutation", deleteCountGenerated.name, {
|
|
7348
7415
|
type: new graphql.GraphQLNonNull(graphql.GraphQLInt),
|
|
7349
7416
|
args: deleteCountGenerated.args,
|
|
7350
7417
|
resolve: deleteCountGenerated.resolver,
|
|
7351
7418
|
description: "How many rows the delete removed. The rows themselves are not read back, which is the point of this mutation."
|
|
7352
|
-
};
|
|
7419
|
+
});
|
|
7353
7420
|
[
|
|
7354
7421
|
...tableFeatures.insert || onConflictInput ? [insertInput] : [],
|
|
7355
7422
|
...onConflictInput ? [onConflictInput] : [],
|