@constructive-io/graphql-query 3.10.4 → 3.11.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.
@@ -1,3 +1,4 @@
1
+ import { fuzzyFindByName } from 'inflekt';
1
2
  const relationalFieldSetCache = new WeakMap();
2
3
  function getRelationalFieldSet(table) {
3
4
  const cached = relationalFieldSetCache.get(table);
@@ -218,11 +219,13 @@ function getRelatedTableScalarFields(relationField, table, allTables) {
218
219
  // No related table found - return empty selection
219
220
  return {};
220
221
  }
221
- // Find the related table in allTables
222
- const relatedTable = allTables.find((t) => t.name === referencedTableName);
222
+ // Find the related table in allTables using shared fuzzy matching from inflekt.
223
+ // Handles PascalCase table names vs snake_case/camelCase/plural codec names.
224
+ const relatedTable = fuzzyFindByName(allTables, referencedTableName, (t) => t.name);
223
225
  if (!relatedTable) {
224
- // Related table not found in schema - return empty selection
225
- return {};
226
+ // Related table not found in schema return fallback { __typename: true }
227
+ // so the query remains valid (nodes need at least one subfield).
228
+ return { __typename: true };
226
229
  }
227
230
  // Get ALL scalar fields from the related table (non-relational fields)
228
231
  // This is completely dynamic based on the actual schema
@@ -8,6 +8,7 @@ import { TypedDocumentString } from '../client/typed-document';
8
8
  import { getCustomAstForCleanField, requiresSubfieldSelection, } from '../custom-ast';
9
9
  import { QueryBuilder } from '../query-builder';
10
10
  import { convertToSelectionOptions, isRelationalField } from './field-selector';
11
+ import { fuzzyFindByName } from 'inflekt';
11
12
  import { normalizeInflectionValue, toCamelCasePlural, toCamelCaseSingular, toCreateInputTypeName, toCreateMutationName, toDeleteInputTypeName, toDeleteMutationName, toFilterTypeName, toOrderByTypeName, toPatchFieldName, toUpdateInputTypeName, toUpdateMutationName, } from './naming-helpers';
12
13
  // Re-export naming helpers for backwards compatibility
13
14
  export { toCamelCasePlural, toOrderByTypeName } from './naming-helpers';
@@ -567,8 +568,9 @@ function findRelatedTable(relationField, table, allTables) {
567
568
  if (!referencedTableName) {
568
569
  return null;
569
570
  }
570
- // Find the related table in allTables
571
- return allTables.find((tbl) => tbl.name === referencedTableName) || null;
571
+ // Find the related table using shared fuzzy matching from inflekt.
572
+ // Handles PascalCase table names vs snake_case/camelCase/plural codec names.
573
+ return fuzzyFindByName(allTables, referencedTableName, (tbl) => tbl.name) ?? null;
572
574
  }
573
575
  /**
574
576
  * Generate FindOne query AST directly from Table
@@ -4,6 +4,7 @@ exports.convertToSelectionOptions = convertToSelectionOptions;
4
4
  exports.isRelationalField = isRelationalField;
5
5
  exports.getAvailableRelations = getAvailableRelations;
6
6
  exports.validateFieldSelection = validateFieldSelection;
7
+ const inflekt_1 = require("inflekt");
7
8
  const relationalFieldSetCache = new WeakMap();
8
9
  function getRelationalFieldSet(table) {
9
10
  const cached = relationalFieldSetCache.get(table);
@@ -224,11 +225,13 @@ function getRelatedTableScalarFields(relationField, table, allTables) {
224
225
  // No related table found - return empty selection
225
226
  return {};
226
227
  }
227
- // Find the related table in allTables
228
- const relatedTable = allTables.find((t) => t.name === referencedTableName);
228
+ // Find the related table in allTables using shared fuzzy matching from inflekt.
229
+ // Handles PascalCase table names vs snake_case/camelCase/plural codec names.
230
+ const relatedTable = (0, inflekt_1.fuzzyFindByName)(allTables, referencedTableName, (t) => t.name);
229
231
  if (!relatedTable) {
230
- // Related table not found in schema - return empty selection
231
- return {};
232
+ // Related table not found in schema return fallback { __typename: true }
233
+ // so the query remains valid (nodes need at least one subfield).
234
+ return { __typename: true };
232
235
  }
233
236
  // Get ALL scalar fields from the related table (non-relational fields)
234
237
  // This is completely dynamic based on the actual schema
@@ -50,6 +50,7 @@ const typed_document_1 = require("../client/typed-document");
50
50
  const custom_ast_1 = require("../custom-ast");
51
51
  const query_builder_1 = require("../query-builder");
52
52
  const field_selector_1 = require("./field-selector");
53
+ const inflekt_1 = require("inflekt");
53
54
  const naming_helpers_1 = require("./naming-helpers");
54
55
  // Re-export naming helpers for backwards compatibility
55
56
  var naming_helpers_2 = require("./naming-helpers");
@@ -611,8 +612,9 @@ function findRelatedTable(relationField, table, allTables) {
611
612
  if (!referencedTableName) {
612
613
  return null;
613
614
  }
614
- // Find the related table in allTables
615
- return allTables.find((tbl) => tbl.name === referencedTableName) || null;
615
+ // Find the related table using shared fuzzy matching from inflekt.
616
+ // Handles PascalCase table names vs snake_case/camelCase/plural codec names.
617
+ return (0, inflekt_1.fuzzyFindByName)(allTables, referencedTableName, (tbl) => tbl.name) ?? null;
616
618
  }
617
619
  /**
618
620
  * Generate FindOne query AST directly from Table
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-query",
3
- "version": "3.10.4",
3
+ "version": "3.11.0",
4
4
  "description": "Constructive GraphQL Query",
5
5
  "author": "Constructive <developers@constructive.io>",
6
6
  "main": "index.js",
@@ -34,10 +34,10 @@
34
34
  "grafast": "1.0.0-rc.9",
35
35
  "graphile-build-pg": "5.0.0-rc.8",
36
36
  "graphile-config": "1.0.0-rc.6",
37
- "graphile-settings": "^4.14.0",
37
+ "graphile-settings": "^4.15.0",
38
38
  "graphql": "16.13.0",
39
39
  "inflection": "^3.0.0",
40
- "inflekt": "^0.3.3",
40
+ "inflekt": "^0.5.0",
41
41
  "lru-cache": "^11.2.7",
42
42
  "postgraphile": "5.0.0-rc.10"
43
43
  },
@@ -51,5 +51,5 @@
51
51
  "devDependencies": {
52
52
  "makage": "^0.1.10"
53
53
  },
54
- "gitHead": "6eb4389816805b64af3a2aa18b29a08f37bb013f"
54
+ "gitHead": "2660dbd64e96cdb785ace8b28fbf9275cb3812aa"
55
55
  }