@vantreeseba/drizzle-graphql 7.0.0 → 7.1.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 +262 -7
- package/dist/README.md +262 -7
- package/dist/index.cjs +214 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -2
- package/dist/index.d.ts +73 -2
- package/dist/index.js +214 -68
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1017,7 +1017,7 @@ var batchedPaginatedRelationQuery = async (db, targetTable, foreignCol, whereCon
|
|
|
1017
1017
|
}
|
|
1018
1018
|
return rows;
|
|
1019
1019
|
};
|
|
1020
|
-
var createRelationResolverFactory = (db, tables, nullOrdering, filterCtx) => ({ tableName, relationName, relEntry, isOne }) => {
|
|
1020
|
+
var createRelationResolverFactory = (db, tables, nullOrdering, filterCtx, limits) => ({ tableName, relationName, relEntry, isOne }) => {
|
|
1021
1021
|
const parentTable = tables[tableName];
|
|
1022
1022
|
const targetTableName = relEntry.targetTableName;
|
|
1023
1023
|
const targetTable = tables[targetTableName];
|
|
@@ -1029,6 +1029,7 @@ var createRelationResolverFactory = (db, tables, nullOrdering, filterCtx) => ({
|
|
|
1029
1029
|
return void 0;
|
|
1030
1030
|
}
|
|
1031
1031
|
const { localColPropName, foreignCol, foreignColPropName } = joinCols;
|
|
1032
|
+
const limitPolicy = isOne ? void 0 : limits?.(targetTableName);
|
|
1032
1033
|
const targetPkNames = relEntry.targetPkNames ?? [];
|
|
1033
1034
|
return async (parent, args, context, info) => {
|
|
1034
1035
|
if (parent[relationName] !== void 0) {
|
|
@@ -1038,7 +1039,8 @@ var createRelationResolverFactory = (db, tables, nullOrdering, filterCtx) => ({
|
|
|
1038
1039
|
if (localValue == null) {
|
|
1039
1040
|
return isOne ? null : [];
|
|
1040
1041
|
}
|
|
1041
|
-
const { where: whereArg, orderBy: orderByArg, limit, offset, after } = args ?? {};
|
|
1042
|
+
const { where: whereArg, orderBy: orderByArg, limit: requestedLimit, offset, after } = args ?? {};
|
|
1043
|
+
const limit = applyLimitPolicy(requestedLimit, limitPolicy, `${tableName}.${relationName}`);
|
|
1042
1044
|
const distinct = (args ?? {}).distinct?.length ? (args ?? {}).distinct : void 0;
|
|
1043
1045
|
const cursorSelected = !isOne && !!info && selectsCursorField(info, targetTable);
|
|
1044
1046
|
let cursorEntries;
|
|
@@ -1152,9 +1154,41 @@ var inputFieldDocs = (docs, column, tableName, columnName, fieldType) => {
|
|
|
1152
1154
|
}
|
|
1153
1155
|
return resolved;
|
|
1154
1156
|
};
|
|
1155
|
-
var
|
|
1157
|
+
var applyLimitPolicy = (limit, policy, fieldName) => {
|
|
1158
|
+
if (!policy) {
|
|
1159
|
+
return limit ?? void 0;
|
|
1160
|
+
}
|
|
1161
|
+
const { defaultLimit, maxLimit, clampToMax } = policy;
|
|
1162
|
+
if (limit == null) {
|
|
1163
|
+
const fallback = defaultLimit ?? maxLimit;
|
|
1164
|
+
if (fallback === void 0) {
|
|
1165
|
+
return void 0;
|
|
1166
|
+
}
|
|
1167
|
+
return maxLimit === void 0 ? fallback : Math.min(fallback, maxLimit);
|
|
1168
|
+
}
|
|
1169
|
+
if (maxLimit !== void 0 && limit > maxLimit) {
|
|
1170
|
+
if (clampToMax) {
|
|
1171
|
+
return maxLimit;
|
|
1172
|
+
}
|
|
1173
|
+
throw new import_graphql5.GraphQLError(`${fieldName}: 'limit' of ${limit} exceeds the maximum of ${maxLimit}.`);
|
|
1174
|
+
}
|
|
1175
|
+
return limit;
|
|
1176
|
+
};
|
|
1177
|
+
var resolveLimitPolicy = (global, table) => {
|
|
1178
|
+
const defaultLimit = table?.defaultLimit ?? global?.defaultLimit;
|
|
1179
|
+
const maxLimit = table?.maxLimit ?? global?.maxLimit;
|
|
1180
|
+
if (defaultLimit === void 0 && maxLimit === void 0) {
|
|
1181
|
+
return void 0;
|
|
1182
|
+
}
|
|
1183
|
+
return { defaultLimit, maxLimit, clampToMax: table?.clampToMax ?? global?.clampToMax ?? false };
|
|
1184
|
+
};
|
|
1185
|
+
var listFieldComplexity = (options, policy) => ({ args, childComplexity }) => {
|
|
1156
1186
|
const limit = args["limit"];
|
|
1157
|
-
const
|
|
1187
|
+
const requested = typeof limit === "number" && limit > 0 ? limit : void 0;
|
|
1188
|
+
let rows = requested ?? policy?.defaultLimit ?? options.defaultListSize;
|
|
1189
|
+
if (policy?.maxLimit !== void 0) {
|
|
1190
|
+
rows = Math.min(rows, policy.maxLimit);
|
|
1191
|
+
}
|
|
1158
1192
|
return rows * Math.max(childComplexity, 1);
|
|
1159
1193
|
};
|
|
1160
1194
|
var aggregateFieldComplexity = (options) => ({ childComplexity }) => options.aggregateCost + childComplexity;
|
|
@@ -1785,7 +1819,11 @@ var generateSelectFields = (tables, tableName, relationMap, fromTableName, fromR
|
|
|
1785
1819
|
},
|
|
1786
1820
|
resolve,
|
|
1787
1821
|
...relationDocs,
|
|
1788
|
-
...cacheCtx.complexity ? {
|
|
1822
|
+
...cacheCtx.complexity ? {
|
|
1823
|
+
extensions: {
|
|
1824
|
+
complexity: listFieldComplexity(cacheCtx.complexity, cacheCtx.limits?.(targetTableName))
|
|
1825
|
+
}
|
|
1826
|
+
} : {}
|
|
1789
1827
|
}
|
|
1790
1828
|
]);
|
|
1791
1829
|
const aggregateFieldName = `${relationName}Aggregate`;
|
|
@@ -2264,7 +2302,7 @@ var extractFilters = (table, tableName, filters, relationCtx) => {
|
|
|
2264
2302
|
}
|
|
2265
2303
|
return variants.length ? variants.length > 1 ? (0, import_drizzle_orm4.and)(...variants) : variants[0] : void 0;
|
|
2266
2304
|
};
|
|
2267
|
-
var extractRelationsParamsInner = (relationMap, tables, tableName, typeName, originField, typeNameMapper, _isInitial = false, filterCtx) => {
|
|
2305
|
+
var extractRelationsParamsInner = (relationMap, tables, tableName, typeName, originField, typeNameMapper, _isInitial = false, filterCtx, limits) => {
|
|
2268
2306
|
const relationsForTable = relationMap[tableName];
|
|
2269
2307
|
if (!relationsForTable) {
|
|
2270
2308
|
return void 0;
|
|
@@ -2308,7 +2346,7 @@ var extractRelationsParamsInner = (relationMap, tables, tableName, typeName, ori
|
|
|
2308
2346
|
const relationField = Object.values(baseField).find((e) => e.name === relName);
|
|
2309
2347
|
const relationArgs = relationField?.args;
|
|
2310
2348
|
const offset = relationArgs?.offset ?? void 0;
|
|
2311
|
-
const limit = relationArgs?.limit ?? void 0;
|
|
2349
|
+
const limit = (0, import_drizzle_orm4.is)(relEntry.relation, import_drizzle_orm4.One) ? relationArgs?.limit ?? void 0 : applyLimitPolicy(relationArgs?.limit, limits?.(targetTableName), `${tableName}.${relName}`);
|
|
2312
2350
|
const relWhere = relationArgs?.where;
|
|
2313
2351
|
thisRecord.where = relWhere ? {
|
|
2314
2352
|
RAW: (aliasedTable2) => extractFilters(aliasedTable2, relName, relWhere, relationFilterCtx(filterCtx, targetTableName))
|
|
@@ -2326,18 +2364,29 @@ var extractRelationsParamsInner = (relationMap, tables, tableName, typeName, ori
|
|
|
2326
2364
|
relationField,
|
|
2327
2365
|
typeNameMapper,
|
|
2328
2366
|
false,
|
|
2329
|
-
filterCtx
|
|
2367
|
+
filterCtx,
|
|
2368
|
+
limits
|
|
2330
2369
|
) : void 0;
|
|
2331
2370
|
thisRecord.with = relWith;
|
|
2332
2371
|
args[relName] = thisRecord;
|
|
2333
2372
|
}
|
|
2334
2373
|
return args;
|
|
2335
2374
|
};
|
|
2336
|
-
var extractRelationsParams = (relationMap, tables, tableName, info, typeName, typeNameMapper, filterCtx) => {
|
|
2375
|
+
var extractRelationsParams = (relationMap, tables, tableName, info, typeName, typeNameMapper, filterCtx, limits) => {
|
|
2337
2376
|
if (!info) {
|
|
2338
2377
|
return void 0;
|
|
2339
2378
|
}
|
|
2340
|
-
return extractRelationsParamsInner(
|
|
2379
|
+
return extractRelationsParamsInner(
|
|
2380
|
+
relationMap,
|
|
2381
|
+
tables,
|
|
2382
|
+
tableName,
|
|
2383
|
+
typeName,
|
|
2384
|
+
info,
|
|
2385
|
+
typeNameMapper,
|
|
2386
|
+
true,
|
|
2387
|
+
filterCtx,
|
|
2388
|
+
limits
|
|
2389
|
+
);
|
|
2341
2390
|
};
|
|
2342
2391
|
var pruneNonEagerRelations = (relationMap, shouldEagerLoad) => {
|
|
2343
2392
|
const out = {};
|
|
@@ -2728,7 +2777,16 @@ var primaryKeyRestriction = (table, pkNames, keys) => {
|
|
|
2728
2777
|
};
|
|
2729
2778
|
var prepareMutationRelationColumns = (params) => {
|
|
2730
2779
|
const { relationMap, tables, tableName, typeName, typeNameMapper, table, pkNames, parsedInfo } = params;
|
|
2731
|
-
const withParams = relationMap[tableName] ? extractRelationsParams(
|
|
2780
|
+
const withParams = relationMap[tableName] ? extractRelationsParams(
|
|
2781
|
+
relationMap,
|
|
2782
|
+
tables,
|
|
2783
|
+
tableName,
|
|
2784
|
+
parsedInfo,
|
|
2785
|
+
typeName,
|
|
2786
|
+
typeNameMapper,
|
|
2787
|
+
void 0,
|
|
2788
|
+
params.limits
|
|
2789
|
+
) : void 0;
|
|
2732
2790
|
const hasRelations = !!(withParams && Object.keys(withParams).length);
|
|
2733
2791
|
const baseColumns = extractSelectedColumnsFromTreeSQLFormat(parsedInfo.fieldsByTypeName[typeName], table, {
|
|
2734
2792
|
tableName,
|
|
@@ -3032,7 +3090,16 @@ var runRelationalSelect = async (opts) => {
|
|
|
3032
3090
|
) : void 0
|
|
3033
3091
|
)
|
|
3034
3092
|
} : void 0,
|
|
3035
|
-
with: relationMap[tableName] ? extractRelationsParams(
|
|
3093
|
+
with: relationMap[tableName] ? extractRelationsParams(
|
|
3094
|
+
relationMap,
|
|
3095
|
+
tables,
|
|
3096
|
+
tableName,
|
|
3097
|
+
parsedInfo,
|
|
3098
|
+
typeName,
|
|
3099
|
+
typeNameMapper,
|
|
3100
|
+
filterCtx,
|
|
3101
|
+
opts.limits
|
|
3102
|
+
) : void 0
|
|
3036
3103
|
};
|
|
3037
3104
|
if (single) {
|
|
3038
3105
|
const result2 = await queryBase.findFirst(params);
|
|
@@ -3562,7 +3629,7 @@ var generateGroupBy = (db, tableName, table, typeName, fieldName, filterArgs, gr
|
|
|
3562
3629
|
};
|
|
3563
3630
|
|
|
3564
3631
|
// src/util/builders/mysql.ts
|
|
3565
|
-
var generateSelectArray = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx, distinctEnabled = true) => {
|
|
3632
|
+
var generateSelectArray = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx, distinctEnabled = true, limits) => {
|
|
3566
3633
|
const queryBase = db.query[tableName];
|
|
3567
3634
|
if (!queryBase) {
|
|
3568
3635
|
throw new Error(
|
|
@@ -3570,6 +3637,7 @@ var generateSelectArray = (db, tableName, tables, relationMap, orderArgs, filter
|
|
|
3570
3637
|
);
|
|
3571
3638
|
}
|
|
3572
3639
|
const table = tables[tableName];
|
|
3640
|
+
const limitPolicy = limits?.(tableName);
|
|
3573
3641
|
const pkNames = mysqlPrimaryKeyPropNames(table);
|
|
3574
3642
|
const queryArgs = selectArrayArgs(
|
|
3575
3643
|
orderArgs,
|
|
@@ -3592,8 +3660,10 @@ var generateSelectArray = (db, tableName, tables, relationMap, orderArgs, filter
|
|
|
3592
3660
|
typeNameMapper,
|
|
3593
3661
|
parsedInfo,
|
|
3594
3662
|
...args,
|
|
3663
|
+
limit: applyLimitPolicy(args.limit, limitPolicy, fieldName),
|
|
3595
3664
|
single: false,
|
|
3596
3665
|
filterCtx,
|
|
3666
|
+
limits,
|
|
3597
3667
|
pkNames,
|
|
3598
3668
|
db: executor,
|
|
3599
3669
|
// MySQL sorts NULLs as the smallest values (first in ASC).
|
|
@@ -3606,7 +3676,7 @@ var generateSelectArray = (db, tableName, tables, relationMap, orderArgs, filter
|
|
|
3606
3676
|
args: queryArgs
|
|
3607
3677
|
};
|
|
3608
3678
|
};
|
|
3609
|
-
var generateSelectSingle = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx) => {
|
|
3679
|
+
var generateSelectSingle = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx, limits) => {
|
|
3610
3680
|
const queryBase = db.query[tableName];
|
|
3611
3681
|
if (!queryBase) {
|
|
3612
3682
|
throw new Error(
|
|
@@ -3634,6 +3704,7 @@ var generateSelectSingle = (db, tableName, tables, relationMap, orderArgs, filte
|
|
|
3634
3704
|
...args,
|
|
3635
3705
|
single: true,
|
|
3636
3706
|
filterCtx,
|
|
3707
|
+
limits,
|
|
3637
3708
|
pkNames,
|
|
3638
3709
|
db: executor
|
|
3639
3710
|
});
|
|
@@ -3848,7 +3919,7 @@ var generateDelete = (db, tableName, table, filterArgs, fieldName, single, requi
|
|
|
3848
3919
|
};
|
|
3849
3920
|
var mysqlPrimaryKeyPropNames = (table) => getPrimaryKeyPropNamesFromConfig(table, import_mysql_core2.getTableConfig);
|
|
3850
3921
|
var generateSchemaData = (db, schema, relations, options) => {
|
|
3851
|
-
const { relationsDepthLimit, prefixes, suffixes, typeNameMapper, shouldEagerLoad, features, complexity } = options;
|
|
3922
|
+
const { relationsDepthLimit, prefixes, suffixes, typeNameMapper, shouldEagerLoad, features, complexity, limits } = options;
|
|
3852
3923
|
const rawSchema = schema;
|
|
3853
3924
|
const schemaEntries = Object.entries(rawSchema);
|
|
3854
3925
|
const tableEntries = schemaEntries.filter(([_key, value]) => (0, import_drizzle_orm6.is)(value, import_mysql_core2.MySqlTable));
|
|
@@ -3873,7 +3944,8 @@ var generateSchemaData = (db, schema, relations, options) => {
|
|
|
3873
3944
|
db,
|
|
3874
3945
|
tables,
|
|
3875
3946
|
"nulls-smallest",
|
|
3876
|
-
filterCtx
|
|
3947
|
+
filterCtx,
|
|
3948
|
+
limits
|
|
3877
3949
|
);
|
|
3878
3950
|
const cacheCtx = {
|
|
3879
3951
|
genericFilterCache: /* @__PURE__ */ new Map(),
|
|
@@ -3888,6 +3960,7 @@ var generateSchemaData = (db, schema, relations, options) => {
|
|
|
3888
3960
|
listRelationFilterCache: /* @__PURE__ */ new Map(),
|
|
3889
3961
|
aggregateTypeCache: /* @__PURE__ */ new Map(),
|
|
3890
3962
|
complexity,
|
|
3963
|
+
limits,
|
|
3891
3964
|
docs: options.docs ?? {},
|
|
3892
3965
|
features
|
|
3893
3966
|
};
|
|
@@ -3958,7 +4031,8 @@ var generateSchemaData = (db, schema, relations, options) => {
|
|
|
3958
4031
|
typeName,
|
|
3959
4032
|
typeNameMapper,
|
|
3960
4033
|
filterCtx,
|
|
3961
|
-
features.distinct
|
|
4034
|
+
features.distinct,
|
|
4035
|
+
limits
|
|
3962
4036
|
);
|
|
3963
4037
|
const selectSingleGenerated = generateSelectSingle(
|
|
3964
4038
|
db,
|
|
@@ -3970,7 +4044,8 @@ var generateSchemaData = (db, schema, relations, options) => {
|
|
|
3970
4044
|
singleFieldName,
|
|
3971
4045
|
typeName,
|
|
3972
4046
|
typeNameMapper,
|
|
3973
|
-
filterCtx
|
|
4047
|
+
filterCtx,
|
|
4048
|
+
limits
|
|
3974
4049
|
);
|
|
3975
4050
|
const insertArrGenerated = features.insert ? generateInsertArray(
|
|
3976
4051
|
db,
|
|
@@ -4120,7 +4195,7 @@ var generateSchemaData = (db, schema, relations, options) => {
|
|
|
4120
4195
|
type: selectArrOutput,
|
|
4121
4196
|
args: selectArrGenerated.args,
|
|
4122
4197
|
resolve: selectArrGenerated.resolver,
|
|
4123
|
-
...complexity ? { extensions: { complexity: listFieldComplexity(complexity) } } : {}
|
|
4198
|
+
...complexity ? { extensions: { complexity: listFieldComplexity(complexity, limits?.(tableName)) } } : {}
|
|
4124
4199
|
};
|
|
4125
4200
|
queries[selectSingleGenerated.name] = {
|
|
4126
4201
|
type: selectSingleOutput,
|
|
@@ -4605,9 +4680,10 @@ var updateWithNestedOps = async (params) => {
|
|
|
4605
4680
|
};
|
|
4606
4681
|
|
|
4607
4682
|
// src/util/builders/pg.ts
|
|
4608
|
-
var generateSelectArray2 = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx, distinctEnabled = true) => {
|
|
4683
|
+
var generateSelectArray2 = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx, distinctEnabled = true, limits) => {
|
|
4609
4684
|
const queryBase = db.query[tableName];
|
|
4610
4685
|
const table = tables[tableName];
|
|
4686
|
+
const limitPolicy = limits?.(tableName);
|
|
4611
4687
|
const pkNames = pgPrimaryKeyPropNames(table);
|
|
4612
4688
|
const queryArgs = selectArrayArgs(
|
|
4613
4689
|
orderArgs,
|
|
@@ -4620,6 +4696,7 @@ var generateSelectArray2 = (db, tableName, tables, relationMap, orderArgs, filte
|
|
|
4620
4696
|
try {
|
|
4621
4697
|
const parsedInfo = (0, import_graphql_parse_resolve_info3.parseResolveInfo)(info, { deep: true });
|
|
4622
4698
|
const { executor, queryBase: requestQueryBase } = resolveQueryExecutor(db, context, tableName, queryBase);
|
|
4699
|
+
const limit = applyLimitPolicy(args.limit, limitPolicy, fieldName);
|
|
4623
4700
|
if (requestQueryBase) {
|
|
4624
4701
|
return await runRelationalSelect({
|
|
4625
4702
|
queryBase: requestQueryBase,
|
|
@@ -4631,15 +4708,17 @@ var generateSelectArray2 = (db, tableName, tables, relationMap, orderArgs, filte
|
|
|
4631
4708
|
typeNameMapper,
|
|
4632
4709
|
parsedInfo,
|
|
4633
4710
|
...args,
|
|
4711
|
+
limit,
|
|
4634
4712
|
single: false,
|
|
4635
4713
|
filterCtx,
|
|
4714
|
+
limits,
|
|
4636
4715
|
pkNames,
|
|
4637
4716
|
db: executor,
|
|
4638
4717
|
// PostgreSQL sorts NULLs as the largest values (last in ASC).
|
|
4639
4718
|
nullOrdering: "nulls-largest"
|
|
4640
4719
|
});
|
|
4641
4720
|
}
|
|
4642
|
-
const { offset,
|
|
4721
|
+
const { offset, orderBy, where, distinct, after } = args;
|
|
4643
4722
|
const selectedColumnsSql = extractSelectedColumnsFromTreeSQLFormat(
|
|
4644
4723
|
parsedInfo.fieldsByTypeName[typeName],
|
|
4645
4724
|
table,
|
|
@@ -4729,7 +4808,7 @@ var generateSelectArray2 = (db, tableName, tables, relationMap, orderArgs, filte
|
|
|
4729
4808
|
args: queryArgs
|
|
4730
4809
|
};
|
|
4731
4810
|
};
|
|
4732
|
-
var generateSelectSingle2 = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx) => {
|
|
4811
|
+
var generateSelectSingle2 = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx, limits) => {
|
|
4733
4812
|
const queryBase = db.query[tableName];
|
|
4734
4813
|
const queryArgs = selectSingleArgs(orderArgs, filterArgs);
|
|
4735
4814
|
const table = tables[tableName];
|
|
@@ -4753,6 +4832,7 @@ var generateSelectSingle2 = (db, tableName, tables, relationMap, orderArgs, filt
|
|
|
4753
4832
|
...args,
|
|
4754
4833
|
single: true,
|
|
4755
4834
|
filterCtx,
|
|
4835
|
+
limits,
|
|
4756
4836
|
pkNames,
|
|
4757
4837
|
db: executor
|
|
4758
4838
|
});
|
|
@@ -4786,7 +4866,7 @@ var generateSelectSingle2 = (db, tableName, tables, relationMap, orderArgs, filt
|
|
|
4786
4866
|
};
|
|
4787
4867
|
};
|
|
4788
4868
|
var pgPrimaryKeyPropNames = (table) => getPrimaryKeyPropNamesFromConfig(table, import_pg_core2.getTableConfig);
|
|
4789
|
-
var generateInsertArray2 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested) => {
|
|
4869
|
+
var generateInsertArray2 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested, limits) => {
|
|
4790
4870
|
const queryArgs = {
|
|
4791
4871
|
values: {
|
|
4792
4872
|
type: new import_graphql9.GraphQLNonNull(new import_graphql9.GraphQLList(new import_graphql9.GraphQLNonNull(baseType)))
|
|
@@ -4815,7 +4895,8 @@ var generateInsertArray2 = (db, tableName, table, tables, relationMap, baseType,
|
|
|
4815
4895
|
typeNameMapper,
|
|
4816
4896
|
table,
|
|
4817
4897
|
pkNames,
|
|
4818
|
-
parsedInfo
|
|
4898
|
+
parsedInfo,
|
|
4899
|
+
limits
|
|
4819
4900
|
});
|
|
4820
4901
|
const returning = nestedEntries ? nested.withJoinColumns(tableName, mergedOps(nestedEntries), { ...columns }, table) : columns;
|
|
4821
4902
|
const runInsert = async (target, values) => {
|
|
@@ -4843,7 +4924,7 @@ var generateInsertArray2 = (db, tableName, table, tables, relationMap, baseType,
|
|
|
4843
4924
|
args: queryArgs
|
|
4844
4925
|
};
|
|
4845
4926
|
};
|
|
4846
|
-
var generateInsertSingle2 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested) => {
|
|
4927
|
+
var generateInsertSingle2 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested, limits) => {
|
|
4847
4928
|
const queryArgs = {
|
|
4848
4929
|
values: {
|
|
4849
4930
|
type: new import_graphql9.GraphQLNonNull(baseType)
|
|
@@ -4869,7 +4950,8 @@ var generateInsertSingle2 = (db, tableName, table, tables, relationMap, baseType
|
|
|
4869
4950
|
typeNameMapper,
|
|
4870
4951
|
table,
|
|
4871
4952
|
pkNames,
|
|
4872
|
-
parsedInfo
|
|
4953
|
+
parsedInfo,
|
|
4954
|
+
limits
|
|
4873
4955
|
});
|
|
4874
4956
|
const returning = nestedEntry ? nested.withJoinColumns(tableName, nestedEntry.ops, { ...columns }, table) : columns;
|
|
4875
4957
|
const runInsert = async (target, values) => {
|
|
@@ -4903,7 +4985,7 @@ var generateInsertSingle2 = (db, tableName, table, tables, relationMap, baseType
|
|
|
4903
4985
|
args: queryArgs
|
|
4904
4986
|
};
|
|
4905
4987
|
};
|
|
4906
|
-
var generateUpsert2 = (db, tableName, table, tables, relationMap, baseType, onConflictType, uniqueSets, fieldName, typeName, single, typeNameMapper, filterCtx, txCtx, nested) => {
|
|
4988
|
+
var generateUpsert2 = (db, tableName, table, tables, relationMap, baseType, onConflictType, uniqueSets, fieldName, typeName, single, typeNameMapper, filterCtx, txCtx, nested, limits) => {
|
|
4907
4989
|
const queryArgs = {
|
|
4908
4990
|
values: {
|
|
4909
4991
|
type: single ? new import_graphql9.GraphQLNonNull(baseType) : new import_graphql9.GraphQLNonNull(new import_graphql9.GraphQLList(new import_graphql9.GraphQLNonNull(baseType)))
|
|
@@ -4935,7 +5017,8 @@ var generateUpsert2 = (db, tableName, table, tables, relationMap, baseType, onCo
|
|
|
4935
5017
|
typeNameMapper,
|
|
4936
5018
|
table,
|
|
4937
5019
|
pkNames,
|
|
4938
|
-
parsedInfo
|
|
5020
|
+
parsedInfo,
|
|
5021
|
+
limits
|
|
4939
5022
|
});
|
|
4940
5023
|
const returning = nestedEntries ? nested.withJoinColumns(tableName, mergedOps(nestedEntries), { ...columns }, table) : columns;
|
|
4941
5024
|
const runUpsert = async (target, values) => {
|
|
@@ -4974,7 +5057,7 @@ var generateUpsert2 = (db, tableName, table, tables, relationMap, baseType, onCo
|
|
|
4974
5057
|
args: queryArgs
|
|
4975
5058
|
};
|
|
4976
5059
|
};
|
|
4977
|
-
var generateUpdate2 = (db, tableName, table, tables, relationMap, setArgs, filterArgs, fieldName, typeName, single, requireWhere, typeNameMapper, filterCtx, txCtx, nested) => {
|
|
5060
|
+
var generateUpdate2 = (db, tableName, table, tables, relationMap, setArgs, filterArgs, fieldName, typeName, single, requireWhere, typeNameMapper, filterCtx, txCtx, nested, limits) => {
|
|
4978
5061
|
const queryArgs = {
|
|
4979
5062
|
set: {
|
|
4980
5063
|
type: new import_graphql9.GraphQLNonNull(setArgs)
|
|
@@ -5001,7 +5084,8 @@ var generateUpdate2 = (db, tableName, table, tables, relationMap, setArgs, filte
|
|
|
5001
5084
|
typeNameMapper,
|
|
5002
5085
|
table,
|
|
5003
5086
|
pkNames,
|
|
5004
|
-
parsedInfo
|
|
5087
|
+
parsedInfo,
|
|
5088
|
+
limits
|
|
5005
5089
|
});
|
|
5006
5090
|
const entry = nested?.enabled(tableName) ? nested.split(tableName, set) : void 0;
|
|
5007
5091
|
const nestedOps = entry && nested.hasOps(entry.ops) ? entry.ops : void 0;
|
|
@@ -5048,7 +5132,7 @@ var generateUpdate2 = (db, tableName, table, tables, relationMap, setArgs, filte
|
|
|
5048
5132
|
args: queryArgs
|
|
5049
5133
|
};
|
|
5050
5134
|
};
|
|
5051
|
-
var generateUpdateMany2 = (db, tableName, table, tables, relationMap, updateManyInput, fieldName, typeName, typeNameMapper, filterCtx, txCtx, nested) => {
|
|
5135
|
+
var generateUpdateMany2 = (db, tableName, table, tables, relationMap, updateManyInput, fieldName, typeName, typeNameMapper, filterCtx, txCtx, nested, limits) => {
|
|
5052
5136
|
const queryArgs = {
|
|
5053
5137
|
updates: {
|
|
5054
5138
|
type: new import_graphql9.GraphQLNonNull(new import_graphql9.GraphQLList(new import_graphql9.GraphQLNonNull(updateManyInput)))
|
|
@@ -5075,7 +5159,8 @@ var generateUpdateMany2 = (db, tableName, table, tables, relationMap, updateMany
|
|
|
5075
5159
|
typeNameMapper,
|
|
5076
5160
|
table,
|
|
5077
5161
|
pkNames,
|
|
5078
|
-
parsedInfo
|
|
5162
|
+
parsedInfo,
|
|
5163
|
+
limits
|
|
5079
5164
|
});
|
|
5080
5165
|
const entries = updates.map(({ where, set }) => {
|
|
5081
5166
|
const split = nested?.enabled(tableName) ? nested.split(tableName, set) : void 0;
|
|
@@ -5193,7 +5278,8 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5193
5278
|
typeNameMapper,
|
|
5194
5279
|
shouldEagerLoad,
|
|
5195
5280
|
features,
|
|
5196
|
-
complexity
|
|
5281
|
+
complexity,
|
|
5282
|
+
limits
|
|
5197
5283
|
} = options;
|
|
5198
5284
|
const schemaEntries = Object.entries(schema);
|
|
5199
5285
|
const tableEntries = schemaEntries.filter(([_key, value]) => (0, import_drizzle_orm8.is)(value, import_pg_core2.PgTable));
|
|
@@ -5213,7 +5299,8 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5213
5299
|
db,
|
|
5214
5300
|
tables,
|
|
5215
5301
|
"nulls-largest",
|
|
5216
|
-
filterCtx
|
|
5302
|
+
filterCtx,
|
|
5303
|
+
limits
|
|
5217
5304
|
);
|
|
5218
5305
|
const cacheCtx = {
|
|
5219
5306
|
genericFilterCache: /* @__PURE__ */ new Map(),
|
|
@@ -5228,6 +5315,7 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5228
5315
|
listRelationFilterCache: /* @__PURE__ */ new Map(),
|
|
5229
5316
|
aggregateTypeCache: /* @__PURE__ */ new Map(),
|
|
5230
5317
|
complexity,
|
|
5318
|
+
limits,
|
|
5231
5319
|
docs: options.docs ?? {},
|
|
5232
5320
|
features
|
|
5233
5321
|
};
|
|
@@ -5297,7 +5385,8 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5297
5385
|
typeName,
|
|
5298
5386
|
typeNameMapper,
|
|
5299
5387
|
filterCtx,
|
|
5300
|
-
features.distinct
|
|
5388
|
+
features.distinct,
|
|
5389
|
+
limits
|
|
5301
5390
|
);
|
|
5302
5391
|
const selectSingleGenerated = generateSelectSingle2(
|
|
5303
5392
|
db,
|
|
@@ -5309,7 +5398,8 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5309
5398
|
singleFieldName,
|
|
5310
5399
|
typeName,
|
|
5311
5400
|
typeNameMapper,
|
|
5312
|
-
filterCtx
|
|
5401
|
+
filterCtx,
|
|
5402
|
+
limits
|
|
5313
5403
|
);
|
|
5314
5404
|
const insertArrGenerated = features.insert ? generateInsertArray2(
|
|
5315
5405
|
db,
|
|
@@ -5323,7 +5413,8 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5323
5413
|
typeNameMapper,
|
|
5324
5414
|
conflictDoNothing,
|
|
5325
5415
|
mutationTxCtx,
|
|
5326
|
-
nestedRuntime
|
|
5416
|
+
nestedRuntime,
|
|
5417
|
+
limits
|
|
5327
5418
|
) : void 0;
|
|
5328
5419
|
const insertSingleGenerated = features.insert ? generateInsertSingle2(
|
|
5329
5420
|
db,
|
|
@@ -5337,7 +5428,8 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5337
5428
|
typeNameMapper,
|
|
5338
5429
|
conflictDoNothing,
|
|
5339
5430
|
mutationTxCtx,
|
|
5340
|
-
nestedRuntime
|
|
5431
|
+
nestedRuntime,
|
|
5432
|
+
limits
|
|
5341
5433
|
) : void 0;
|
|
5342
5434
|
const uniqueSets = features.upsert ? getUniqueColumnSets(schema[tableName], import_pg_core2.getTableConfig) : [];
|
|
5343
5435
|
const onConflictInput = features.upsert ? generateOnConflictInput({
|
|
@@ -5362,7 +5454,8 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5362
5454
|
typeNameMapper,
|
|
5363
5455
|
filterCtx,
|
|
5364
5456
|
mutationTxCtx,
|
|
5365
|
-
nestedRuntime
|
|
5457
|
+
nestedRuntime,
|
|
5458
|
+
limits
|
|
5366
5459
|
) : void 0;
|
|
5367
5460
|
const upsertSingleGenerated = onConflictInput ? generateUpsert2(
|
|
5368
5461
|
db,
|
|
@@ -5379,7 +5472,8 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5379
5472
|
typeNameMapper,
|
|
5380
5473
|
filterCtx,
|
|
5381
5474
|
mutationTxCtx,
|
|
5382
|
-
nestedRuntime
|
|
5475
|
+
nestedRuntime,
|
|
5476
|
+
limits
|
|
5383
5477
|
) : void 0;
|
|
5384
5478
|
const updateGenerated = features.update ? generateUpdate2(
|
|
5385
5479
|
db,
|
|
@@ -5396,7 +5490,8 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5396
5490
|
typeNameMapper,
|
|
5397
5491
|
filterCtx,
|
|
5398
5492
|
mutationTxCtx,
|
|
5399
|
-
nestedRuntime
|
|
5493
|
+
nestedRuntime,
|
|
5494
|
+
limits
|
|
5400
5495
|
) : void 0;
|
|
5401
5496
|
const updateSingleGenerated = features.update ? generateUpdate2(
|
|
5402
5497
|
db,
|
|
@@ -5413,7 +5508,8 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5413
5508
|
typeNameMapper,
|
|
5414
5509
|
filterCtx,
|
|
5415
5510
|
mutationTxCtx,
|
|
5416
|
-
nestedRuntime
|
|
5511
|
+
nestedRuntime,
|
|
5512
|
+
limits
|
|
5417
5513
|
) : void 0;
|
|
5418
5514
|
const updateManyInput = features.update && features.updateMany ? generateUpdateManyInput({ typeName, updatePrefix: prefixes.update, updateInput, tableFilters }) : void 0;
|
|
5419
5515
|
const updateManyGenerated = updateManyInput ? generateUpdateMany2(
|
|
@@ -5428,7 +5524,8 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5428
5524
|
typeNameMapper,
|
|
5429
5525
|
filterCtx,
|
|
5430
5526
|
mutationTxCtx,
|
|
5431
|
-
nestedRuntime
|
|
5527
|
+
nestedRuntime,
|
|
5528
|
+
limits
|
|
5432
5529
|
) : void 0;
|
|
5433
5530
|
const deleteGenerated = features.delete ? generateDelete2(
|
|
5434
5531
|
db,
|
|
@@ -5508,7 +5605,7 @@ function generateSchemaData2(db, schema, relations, options) {
|
|
|
5508
5605
|
type: selectArrOutput,
|
|
5509
5606
|
args: selectArrGenerated.args,
|
|
5510
5607
|
resolve: selectArrGenerated.resolver,
|
|
5511
|
-
...complexity ? { extensions: { complexity: listFieldComplexity(complexity) } } : {}
|
|
5608
|
+
...complexity ? { extensions: { complexity: listFieldComplexity(complexity, limits?.(tableName)) } } : {}
|
|
5512
5609
|
};
|
|
5513
5610
|
queries[selectSingleGenerated.name] = {
|
|
5514
5611
|
type: selectSingleOutput,
|
|
@@ -5665,7 +5762,7 @@ var import_drizzle_orm9 = require("drizzle-orm");
|
|
|
5665
5762
|
var import_sqlite_core2 = require("drizzle-orm/sqlite-core");
|
|
5666
5763
|
var import_graphql10 = require("graphql");
|
|
5667
5764
|
var import_graphql_parse_resolve_info4 = require("graphql-parse-resolve-info");
|
|
5668
|
-
var generateSelectArray3 = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx, distinctEnabled = true) => {
|
|
5765
|
+
var generateSelectArray3 = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx, distinctEnabled = true, limits) => {
|
|
5669
5766
|
const queryBase = db.query[tableName];
|
|
5670
5767
|
if (!queryBase) {
|
|
5671
5768
|
throw new Error(
|
|
@@ -5673,6 +5770,7 @@ var generateSelectArray3 = (db, tableName, tables, relationMap, orderArgs, filte
|
|
|
5673
5770
|
);
|
|
5674
5771
|
}
|
|
5675
5772
|
const table = tables[tableName];
|
|
5773
|
+
const limitPolicy = limits?.(tableName);
|
|
5676
5774
|
const pkNames = sqlitePrimaryKeyPropNames(table);
|
|
5677
5775
|
const queryArgs = selectArrayArgs(
|
|
5678
5776
|
orderArgs,
|
|
@@ -5695,8 +5793,10 @@ var generateSelectArray3 = (db, tableName, tables, relationMap, orderArgs, filte
|
|
|
5695
5793
|
typeNameMapper,
|
|
5696
5794
|
parsedInfo,
|
|
5697
5795
|
...args,
|
|
5796
|
+
limit: applyLimitPolicy(args.limit, limitPolicy, fieldName),
|
|
5698
5797
|
single: false,
|
|
5699
5798
|
filterCtx,
|
|
5799
|
+
limits,
|
|
5700
5800
|
pkNames,
|
|
5701
5801
|
db: executor,
|
|
5702
5802
|
// SQLite sorts NULLs as the smallest values (first in ASC).
|
|
@@ -5709,7 +5809,7 @@ var generateSelectArray3 = (db, tableName, tables, relationMap, orderArgs, filte
|
|
|
5709
5809
|
args: queryArgs
|
|
5710
5810
|
};
|
|
5711
5811
|
};
|
|
5712
|
-
var generateSelectSingle3 = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx) => {
|
|
5812
|
+
var generateSelectSingle3 = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx, limits) => {
|
|
5713
5813
|
const queryBase = db.query[tableName];
|
|
5714
5814
|
if (!queryBase) {
|
|
5715
5815
|
throw new Error(
|
|
@@ -5737,6 +5837,7 @@ var generateSelectSingle3 = (db, tableName, tables, relationMap, orderArgs, filt
|
|
|
5737
5837
|
...args,
|
|
5738
5838
|
single: true,
|
|
5739
5839
|
filterCtx,
|
|
5840
|
+
limits,
|
|
5740
5841
|
pkNames,
|
|
5741
5842
|
db: executor
|
|
5742
5843
|
});
|
|
@@ -5748,7 +5849,7 @@ var generateSelectSingle3 = (db, tableName, tables, relationMap, orderArgs, filt
|
|
|
5748
5849
|
};
|
|
5749
5850
|
};
|
|
5750
5851
|
var sqlitePrimaryKeyPropNames = (table) => getPrimaryKeyPropNamesFromConfig(table, import_sqlite_core2.getTableConfig);
|
|
5751
|
-
var generateInsertArray3 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested) => {
|
|
5852
|
+
var generateInsertArray3 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested, limits) => {
|
|
5752
5853
|
const queryArgs = {
|
|
5753
5854
|
values: {
|
|
5754
5855
|
type: new import_graphql10.GraphQLNonNull(new import_graphql10.GraphQLList(new import_graphql10.GraphQLNonNull(baseType)))
|
|
@@ -5777,7 +5878,8 @@ var generateInsertArray3 = (db, tableName, table, tables, relationMap, baseType,
|
|
|
5777
5878
|
typeNameMapper,
|
|
5778
5879
|
table,
|
|
5779
5880
|
pkNames,
|
|
5780
|
-
parsedInfo
|
|
5881
|
+
parsedInfo,
|
|
5882
|
+
limits
|
|
5781
5883
|
});
|
|
5782
5884
|
const returning = nestedEntries ? nested.withJoinColumns(tableName, mergedOps(nestedEntries), { ...columns }, table) : columns;
|
|
5783
5885
|
const runInsert = async (target, values) => {
|
|
@@ -5805,7 +5907,7 @@ var generateInsertArray3 = (db, tableName, table, tables, relationMap, baseType,
|
|
|
5805
5907
|
args: queryArgs
|
|
5806
5908
|
};
|
|
5807
5909
|
};
|
|
5808
|
-
var generateInsertSingle3 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested) => {
|
|
5910
|
+
var generateInsertSingle3 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested, limits) => {
|
|
5809
5911
|
const queryArgs = {
|
|
5810
5912
|
values: {
|
|
5811
5913
|
type: new import_graphql10.GraphQLNonNull(baseType)
|
|
@@ -5831,7 +5933,8 @@ var generateInsertSingle3 = (db, tableName, table, tables, relationMap, baseType
|
|
|
5831
5933
|
typeNameMapper,
|
|
5832
5934
|
table,
|
|
5833
5935
|
pkNames,
|
|
5834
|
-
parsedInfo
|
|
5936
|
+
parsedInfo,
|
|
5937
|
+
limits
|
|
5835
5938
|
});
|
|
5836
5939
|
const returning = nestedEntry ? nested.withJoinColumns(tableName, nestedEntry.ops, { ...columns }, table) : columns;
|
|
5837
5940
|
const runInsert = async (target, values) => {
|
|
@@ -5865,7 +5968,7 @@ var generateInsertSingle3 = (db, tableName, table, tables, relationMap, baseType
|
|
|
5865
5968
|
args: queryArgs
|
|
5866
5969
|
};
|
|
5867
5970
|
};
|
|
5868
|
-
var generateUpsert3 = (db, tableName, table, tables, relationMap, baseType, onConflictType, uniqueSets, fieldName, typeName, single, typeNameMapper, filterCtx, txCtx, nested) => {
|
|
5971
|
+
var generateUpsert3 = (db, tableName, table, tables, relationMap, baseType, onConflictType, uniqueSets, fieldName, typeName, single, typeNameMapper, filterCtx, txCtx, nested, limits) => {
|
|
5869
5972
|
const queryArgs = {
|
|
5870
5973
|
values: {
|
|
5871
5974
|
type: single ? new import_graphql10.GraphQLNonNull(baseType) : new import_graphql10.GraphQLNonNull(new import_graphql10.GraphQLList(new import_graphql10.GraphQLNonNull(baseType)))
|
|
@@ -5897,7 +6000,8 @@ var generateUpsert3 = (db, tableName, table, tables, relationMap, baseType, onCo
|
|
|
5897
6000
|
typeNameMapper,
|
|
5898
6001
|
table,
|
|
5899
6002
|
pkNames,
|
|
5900
|
-
parsedInfo
|
|
6003
|
+
parsedInfo,
|
|
6004
|
+
limits
|
|
5901
6005
|
});
|
|
5902
6006
|
const returning = nestedEntries ? nested.withJoinColumns(tableName, mergedOps(nestedEntries), { ...columns }, table) : columns;
|
|
5903
6007
|
const runUpsert = async (target, values) => {
|
|
@@ -5936,7 +6040,7 @@ var generateUpsert3 = (db, tableName, table, tables, relationMap, baseType, onCo
|
|
|
5936
6040
|
args: queryArgs
|
|
5937
6041
|
};
|
|
5938
6042
|
};
|
|
5939
|
-
var generateUpdate3 = (db, tableName, table, tables, relationMap, setArgs, filterArgs, fieldName, typeName, single, requireWhere, typeNameMapper, filterCtx, txCtx, nested) => {
|
|
6043
|
+
var generateUpdate3 = (db, tableName, table, tables, relationMap, setArgs, filterArgs, fieldName, typeName, single, requireWhere, typeNameMapper, filterCtx, txCtx, nested, limits) => {
|
|
5940
6044
|
const queryArgs = {
|
|
5941
6045
|
set: {
|
|
5942
6046
|
type: new import_graphql10.GraphQLNonNull(setArgs)
|
|
@@ -5963,7 +6067,8 @@ var generateUpdate3 = (db, tableName, table, tables, relationMap, setArgs, filte
|
|
|
5963
6067
|
typeNameMapper,
|
|
5964
6068
|
table,
|
|
5965
6069
|
pkNames,
|
|
5966
|
-
parsedInfo
|
|
6070
|
+
parsedInfo,
|
|
6071
|
+
limits
|
|
5967
6072
|
});
|
|
5968
6073
|
const entry = nested?.enabled(tableName) ? nested.split(tableName, set) : void 0;
|
|
5969
6074
|
const nestedOps = entry && nested.hasOps(entry.ops) ? entry.ops : void 0;
|
|
@@ -6010,7 +6115,7 @@ var generateUpdate3 = (db, tableName, table, tables, relationMap, setArgs, filte
|
|
|
6010
6115
|
args: queryArgs
|
|
6011
6116
|
};
|
|
6012
6117
|
};
|
|
6013
|
-
var generateUpdateMany3 = (db, tableName, table, tables, relationMap, updateManyInput, fieldName, typeName, typeNameMapper, filterCtx, txCtx, nested) => {
|
|
6118
|
+
var generateUpdateMany3 = (db, tableName, table, tables, relationMap, updateManyInput, fieldName, typeName, typeNameMapper, filterCtx, txCtx, nested, limits) => {
|
|
6014
6119
|
const queryArgs = {
|
|
6015
6120
|
updates: {
|
|
6016
6121
|
type: new import_graphql10.GraphQLNonNull(new import_graphql10.GraphQLList(new import_graphql10.GraphQLNonNull(updateManyInput)))
|
|
@@ -6037,7 +6142,8 @@ var generateUpdateMany3 = (db, tableName, table, tables, relationMap, updateMany
|
|
|
6037
6142
|
typeNameMapper,
|
|
6038
6143
|
table,
|
|
6039
6144
|
pkNames,
|
|
6040
|
-
parsedInfo
|
|
6145
|
+
parsedInfo,
|
|
6146
|
+
limits
|
|
6041
6147
|
});
|
|
6042
6148
|
const entries = updates.map(({ where, set }) => {
|
|
6043
6149
|
const split = nested?.enabled(tableName) ? nested.split(tableName, set) : void 0;
|
|
@@ -6183,7 +6289,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6183
6289
|
typeNameMapper,
|
|
6184
6290
|
shouldEagerLoad,
|
|
6185
6291
|
features,
|
|
6186
|
-
complexity
|
|
6292
|
+
complexity,
|
|
6293
|
+
limits
|
|
6187
6294
|
} = options;
|
|
6188
6295
|
const rawSchema = schema;
|
|
6189
6296
|
const schemaEntries = Object.entries(rawSchema);
|
|
@@ -6204,7 +6311,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6204
6311
|
db,
|
|
6205
6312
|
tables,
|
|
6206
6313
|
"nulls-smallest",
|
|
6207
|
-
filterCtx
|
|
6314
|
+
filterCtx,
|
|
6315
|
+
limits
|
|
6208
6316
|
);
|
|
6209
6317
|
const cacheCtx = {
|
|
6210
6318
|
genericFilterCache: /* @__PURE__ */ new Map(),
|
|
@@ -6219,6 +6327,7 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6219
6327
|
listRelationFilterCache: /* @__PURE__ */ new Map(),
|
|
6220
6328
|
aggregateTypeCache: /* @__PURE__ */ new Map(),
|
|
6221
6329
|
complexity,
|
|
6330
|
+
limits,
|
|
6222
6331
|
docs: options.docs ?? {},
|
|
6223
6332
|
features
|
|
6224
6333
|
};
|
|
@@ -6298,7 +6407,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6298
6407
|
typeName,
|
|
6299
6408
|
typeNameMapper,
|
|
6300
6409
|
filterCtx,
|
|
6301
|
-
features.distinct
|
|
6410
|
+
features.distinct,
|
|
6411
|
+
limits
|
|
6302
6412
|
);
|
|
6303
6413
|
const selectSingleGenerated = generateSelectSingle3(
|
|
6304
6414
|
db,
|
|
@@ -6310,7 +6420,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6310
6420
|
singleFieldName,
|
|
6311
6421
|
typeName,
|
|
6312
6422
|
typeNameMapper,
|
|
6313
|
-
filterCtx
|
|
6423
|
+
filterCtx,
|
|
6424
|
+
limits
|
|
6314
6425
|
);
|
|
6315
6426
|
const insertArrGenerated = features.insert ? generateInsertArray3(
|
|
6316
6427
|
db,
|
|
@@ -6324,7 +6435,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6324
6435
|
typeNameMapper,
|
|
6325
6436
|
conflictDoNothing,
|
|
6326
6437
|
mutationTxCtx,
|
|
6327
|
-
nestedRuntime
|
|
6438
|
+
nestedRuntime,
|
|
6439
|
+
limits
|
|
6328
6440
|
) : void 0;
|
|
6329
6441
|
const insertSingleGenerated = features.insert ? generateInsertSingle3(
|
|
6330
6442
|
db,
|
|
@@ -6338,7 +6450,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6338
6450
|
typeNameMapper,
|
|
6339
6451
|
conflictDoNothing,
|
|
6340
6452
|
mutationTxCtx,
|
|
6341
|
-
nestedRuntime
|
|
6453
|
+
nestedRuntime,
|
|
6454
|
+
limits
|
|
6342
6455
|
) : void 0;
|
|
6343
6456
|
const uniqueSets = features.upsert ? getUniqueColumnSets(schema[tableName], import_sqlite_core2.getTableConfig) : [];
|
|
6344
6457
|
const onConflictInput = features.upsert ? generateOnConflictInput({
|
|
@@ -6363,7 +6476,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6363
6476
|
typeNameMapper,
|
|
6364
6477
|
filterCtx,
|
|
6365
6478
|
mutationTxCtx,
|
|
6366
|
-
nestedRuntime
|
|
6479
|
+
nestedRuntime,
|
|
6480
|
+
limits
|
|
6367
6481
|
) : void 0;
|
|
6368
6482
|
const upsertSingleGenerated = onConflictInput ? generateUpsert3(
|
|
6369
6483
|
db,
|
|
@@ -6380,7 +6494,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6380
6494
|
typeNameMapper,
|
|
6381
6495
|
filterCtx,
|
|
6382
6496
|
mutationTxCtx,
|
|
6383
|
-
nestedRuntime
|
|
6497
|
+
nestedRuntime,
|
|
6498
|
+
limits
|
|
6384
6499
|
) : void 0;
|
|
6385
6500
|
const updateGenerated = features.update ? generateUpdate3(
|
|
6386
6501
|
db,
|
|
@@ -6397,7 +6512,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6397
6512
|
typeNameMapper,
|
|
6398
6513
|
filterCtx,
|
|
6399
6514
|
mutationTxCtx,
|
|
6400
|
-
nestedRuntime
|
|
6515
|
+
nestedRuntime,
|
|
6516
|
+
limits
|
|
6401
6517
|
) : void 0;
|
|
6402
6518
|
const updateSingleGenerated = features.update ? generateUpdate3(
|
|
6403
6519
|
db,
|
|
@@ -6414,7 +6530,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6414
6530
|
typeNameMapper,
|
|
6415
6531
|
filterCtx,
|
|
6416
6532
|
mutationTxCtx,
|
|
6417
|
-
nestedRuntime
|
|
6533
|
+
nestedRuntime,
|
|
6534
|
+
limits
|
|
6418
6535
|
) : void 0;
|
|
6419
6536
|
const updateManyInput = features.update && features.updateMany ? generateUpdateManyInput({ typeName, updatePrefix: prefixes.update, updateInput, tableFilters }) : void 0;
|
|
6420
6537
|
const updateManyGenerated = updateManyInput ? generateUpdateMany3(
|
|
@@ -6429,7 +6546,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6429
6546
|
typeNameMapper,
|
|
6430
6547
|
filterCtx,
|
|
6431
6548
|
mutationTxCtx,
|
|
6432
|
-
nestedRuntime
|
|
6549
|
+
nestedRuntime,
|
|
6550
|
+
limits
|
|
6433
6551
|
) : void 0;
|
|
6434
6552
|
const deleteGenerated = features.delete ? generateDelete3(
|
|
6435
6553
|
db,
|
|
@@ -6509,7 +6627,7 @@ var generateSchemaData3 = (db, schema, relations, options) => {
|
|
|
6509
6627
|
type: selectArrOutput,
|
|
6510
6628
|
args: selectArrGenerated.args,
|
|
6511
6629
|
resolve: selectArrGenerated.resolver,
|
|
6512
|
-
...complexity ? { extensions: { complexity: listFieldComplexity(complexity) } } : {}
|
|
6630
|
+
...complexity ? { extensions: { complexity: listFieldComplexity(complexity, limits?.(tableName)) } } : {}
|
|
6513
6631
|
};
|
|
6514
6632
|
queries[selectSingleGenerated.name] = {
|
|
6515
6633
|
type: selectSingleOutput,
|
|
@@ -6705,6 +6823,33 @@ var buildSchema = (db, config) => {
|
|
|
6705
6823
|
};
|
|
6706
6824
|
const transactionsOpt = config?.transactions;
|
|
6707
6825
|
const transactions = transactionsOpt === void 0 || transactionsOpt === "none" ? void 0 : { timeoutMs: (transactionsOpt === "auto" ? void 0 : transactionsOpt.timeoutMs) ?? 3e4 };
|
|
6826
|
+
const limitsConfig = config?.limits;
|
|
6827
|
+
if (limitsConfig) {
|
|
6828
|
+
const check = (policy, where) => {
|
|
6829
|
+
for (const key of ["defaultLimit", "maxLimit"]) {
|
|
6830
|
+
const value = policy[key];
|
|
6831
|
+
if (value === void 0) {
|
|
6832
|
+
continue;
|
|
6833
|
+
}
|
|
6834
|
+
if (!Number.isInteger(value) || value < 1) {
|
|
6835
|
+
throw new Error(`Drizzle-GraphQL Error: config.limits${where}.${key} must be a positive integer.`);
|
|
6836
|
+
}
|
|
6837
|
+
}
|
|
6838
|
+
};
|
|
6839
|
+
check(limitsConfig, "");
|
|
6840
|
+
for (const [tableName, policy] of Object.entries(limitsConfig.tables ?? {})) {
|
|
6841
|
+
check(policy, `.tables.${tableName}`);
|
|
6842
|
+
}
|
|
6843
|
+
}
|
|
6844
|
+
const limitPolicyCache = /* @__PURE__ */ new Map();
|
|
6845
|
+
const limits = limitsConfig ? (tableName) => {
|
|
6846
|
+
if (limitPolicyCache.has(tableName)) {
|
|
6847
|
+
return limitPolicyCache.get(tableName);
|
|
6848
|
+
}
|
|
6849
|
+
const resolved = resolveLimitPolicy(limitsConfig, limitsConfig.tables?.[tableName]);
|
|
6850
|
+
limitPolicyCache.set(tableName, resolved);
|
|
6851
|
+
return resolved;
|
|
6852
|
+
} : void 0;
|
|
6708
6853
|
const eagerOpt = config?.eagerLoadRelations;
|
|
6709
6854
|
const shouldEagerLoad = eagerOpt === void 0 || eagerOpt === true ? () => true : eagerOpt === false ? () => false : eagerOpt;
|
|
6710
6855
|
if (!typeNameMapper && suffixes.list === suffixes.single) {
|
|
@@ -6737,6 +6882,7 @@ var buildSchema = (db, config) => {
|
|
|
6737
6882
|
mapColumnType: config?.mapColumnType,
|
|
6738
6883
|
enumNameMapper: config?.enumNameMapper,
|
|
6739
6884
|
transactions,
|
|
6885
|
+
limits,
|
|
6740
6886
|
docs: {
|
|
6741
6887
|
describeColumn: config?.describeColumn,
|
|
6742
6888
|
describeTable: config?.describeTable,
|