@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.js
CHANGED
|
@@ -3154,16 +3154,23 @@ const extractRelationsParams = (relationMap, tables, tableName, info, typeName,
|
|
|
3154
3154
|
if (!info) return;
|
|
3155
3155
|
const relationsForTable = relationMap[tableName];
|
|
3156
3156
|
if (!relationsForTable) return;
|
|
3157
|
-
const baseField =
|
|
3157
|
+
const baseField = info.fieldsByTypeName[typeName];
|
|
3158
3158
|
if (!baseField) return;
|
|
3159
|
+
const selectionsByName = /* @__PURE__ */ new Map();
|
|
3160
|
+
for (const selection of Object.values(baseField)) {
|
|
3161
|
+
const selections = selectionsByName.get(selection.name);
|
|
3162
|
+
if (selections) selections.push(selection);
|
|
3163
|
+
else selectionsByName.set(selection.name, [selection]);
|
|
3164
|
+
}
|
|
3159
3165
|
const args = {};
|
|
3160
3166
|
for (const [relName, relEntry] of Object.entries(relationsForTable)) {
|
|
3161
3167
|
const { targetTableName, targetPkNames } = relEntry;
|
|
3162
3168
|
const relTypeName = resolveObjectTypeName(targetTableName, typeNameMapper, resolveName);
|
|
3163
|
-
const
|
|
3164
|
-
if (!
|
|
3165
|
-
|
|
3166
|
-
|
|
3169
|
+
const selections = selectionsByName.get(relName);
|
|
3170
|
+
if (!selections) continue;
|
|
3171
|
+
const field = selections[0];
|
|
3172
|
+
if (selections.length > 1) continue;
|
|
3173
|
+
const relFieldSelection = field.fieldsByTypeName[relTypeName];
|
|
3167
3174
|
if (!relFieldSelection) continue;
|
|
3168
3175
|
const eagerArgs = field.args;
|
|
3169
3176
|
if (!is(relEntry.relation ?? relEntry, One) && (eagerArgs?.after != null || !!(eagerArgs?.distinct)?.length || isCursorFieldSelected(relFieldSelection, tables[targetTableName]))) continue;
|
|
@@ -3175,8 +3182,7 @@ const extractRelationsParams = (relationMap, tables, tableName, info, typeName,
|
|
|
3175
3182
|
});
|
|
3176
3183
|
const thisRecord = {};
|
|
3177
3184
|
thisRecord.columns = columns;
|
|
3178
|
-
const
|
|
3179
|
-
const relationArgs = is(relEntry.relation, One) ? relationField?.args : relationField && withDefaultOrderBy(relationField.args ?? {}, targetTableName, defaultOrderBy);
|
|
3185
|
+
const relationArgs = is(relEntry.relation, One) ? field.args : withDefaultOrderBy(field.args ?? {}, targetTableName, defaultOrderBy);
|
|
3180
3186
|
const offset = relationArgs?.offset ?? void 0;
|
|
3181
3187
|
const limit = is(relEntry.relation, One) ? relationArgs?.limit ?? void 0 : applyLimitPolicy(relationArgs?.limit, limits?.(targetTableName), {
|
|
3182
3188
|
table: targetTableName,
|
|
@@ -3191,7 +3197,7 @@ const extractRelationsParams = (relationMap, tables, tableName, info, typeName,
|
|
|
3191
3197
|
thisRecord.orderBy = relationArgs?.orderBy ? (aliasedTable) => extractOrderBy(aliasedTable, relationArgs.orderBy, relationFilterCtx(filterCtx, targetTableName), relWhere) : hasPagination && pkNames.length ? (aliasedTable) => primaryKeyOrderExprs(aliasedTable, pkNames) : void 0;
|
|
3192
3198
|
thisRecord.offset = offset;
|
|
3193
3199
|
thisRecord.limit = limit;
|
|
3194
|
-
thisRecord.with = extractRelationsParams(relationMap, tables, targetTableName,
|
|
3200
|
+
thisRecord.with = extractRelationsParams(relationMap, tables, targetTableName, field, relTypeName, options);
|
|
3195
3201
|
args[relName] = thisRecord;
|
|
3196
3202
|
}
|
|
3197
3203
|
return args;
|