@vantreeseba/drizzle-graphql 10.0.2 → 10.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +14 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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;
|