drizzle-graphql-plus 0.8.10 → 0.8.11

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/index.cjs CHANGED
@@ -495,6 +495,18 @@ var generateTableFilterTypeCached = (table, tableName) => {
495
495
  filterTypeMap.set(table, filters);
496
496
  return filters;
497
497
  };
498
+ var interfaceTypeMap = /* @__PURE__ */ new WeakMap();
499
+ var generateTableInterfaceTypeCached = (table, tableName) => {
500
+ if (interfaceTypeMap.has(table))
501
+ return interfaceTypeMap.get(table);
502
+ const tableFields = generateTableSelectTypeFieldsCached(table, tableName);
503
+ const interfaceType = new import_graphql3.GraphQLInterfaceType({
504
+ name: `${capitalize(tableName)}Fields`,
505
+ fields: tableFields
506
+ });
507
+ interfaceTypeMap.set(table, interfaceType);
508
+ return interfaceType;
509
+ };
498
510
  var generateSelectFields = (tables, tableName, relationMap, typeName, withOrder, relationsDepthLimit, currentDepth = 0, usedTables = /* @__PURE__ */ new Set()) => {
499
511
  const relations = relationMap[tableName];
500
512
  const relationEntries = relations ? Object.entries(relations) : [];
@@ -526,9 +538,15 @@ var generateSelectFields = (tables, tableName, relationMap, typeName, withOrder,
526
538
  newDepth,
527
539
  updatedUsedTables
528
540
  );
541
+ const targetTable = tables[targetTableName];
542
+ const targetInterface = generateTableInterfaceTypeCached(
543
+ targetTable,
544
+ targetTableName
545
+ );
529
546
  const relType = new import_graphql3.GraphQLObjectType({
530
547
  name: relTypeName,
531
- fields: { ...relData.tableFields, ...relData.relationFields }
548
+ fields: { ...relData.tableFields, ...relData.relationFields },
549
+ interfaces: [targetInterface]
532
550
  });
533
551
  if (isOne) {
534
552
  rawRelationFields.push([
@@ -606,10 +624,10 @@ var generateTableTypes = (tableName, tables, relationMap, withReturning, relatio
606
624
  name: `${stylizedName}InsertInput`,
607
625
  fields: insertFields
608
626
  });
609
- const tableFieldsInterface = new import_graphql3.GraphQLInterfaceType({
610
- name: `${stylizedName}Fields`,
611
- fields: tableFields
612
- });
627
+ const tableFieldsInterface = generateTableInterfaceTypeCached(
628
+ table,
629
+ tableName
630
+ );
613
631
  const selectSingleOutput = new import_graphql3.GraphQLObjectType({
614
632
  name: `${stylizedName}SelectItem`,
615
633
  fields: { ...tableFields, ...relationFields },