graphile-postgis 2.11.1 → 2.11.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.
@@ -195,6 +195,11 @@ export function collectSpatialRelations(build) {
195
195
  const pgRegistry = build.input?.pgRegistry;
196
196
  if (!pgRegistry)
197
197
  return [];
198
+ // Inflection is used to normalize user-supplied identifiers (the
199
+ // parametric arg name, e.g. `travel_distance` → `travelDistance`) into the
200
+ // GraphQL casing conventions. Fall back to identity if not available
201
+ // (e.g. when invoked from unit tests with a stub build).
202
+ const camelCase = build.inflection?.camelCase?.bind(build.inflection) ?? ((s) => s);
198
203
  const relations = [];
199
204
  for (const resource of Object.values(pgRegistry.pgResources)) {
200
205
  if (resource.parameters)
@@ -254,7 +259,7 @@ export function collectSpatialRelations(build) {
254
259
  targetResource: target.resource,
255
260
  targetAttributeName: target.attributeName,
256
261
  operator: OPERATOR_REGISTRY[parsed.operator],
257
- paramFieldName: parsed.paramName,
262
+ paramFieldName: parsed.paramName ? camelCase(parsed.paramName) : null,
258
263
  isSelfRelation,
259
264
  ownerPkAttributes,
260
265
  targetPkAttributes,
@@ -280,7 +285,10 @@ export function collectSpatialRelations(build) {
280
285
  function spatialFilterTypeName(build, rel) {
281
286
  const { inflection } = build;
282
287
  const ownerTypeName = inflection.tableType(rel.ownerCodec);
283
- const rel0 = rel.relationName.charAt(0).toUpperCase() + rel.relationName.slice(1);
288
+ // Normalize the user-supplied relation name (which may be snake_case,
289
+ // kebab-case, or mixed) into PascalCase so the type name is consistent
290
+ // with every other generated GraphQL type name.
291
+ const rel0 = inflection.upperCamelCase(rel.relationName);
284
292
  return `${ownerTypeName}Spatial${rel0}Filter`;
285
293
  }
286
294
  /**
@@ -423,7 +431,10 @@ export const PostgisSpatialRelationsPlugin = {
423
431
  const FilterType = build.getTypeByName(filterTypeName);
424
432
  if (!FilterType)
425
433
  continue;
426
- const fieldName = rel.relationName;
434
+ // Normalize the user-supplied relation name (which may be
435
+ // snake_case, kebab-case, or mixed) into camelCase so the GraphQL
436
+ // field name matches the casing of every other generated field.
437
+ const fieldName = inflection.camelCase(rel.relationName);
427
438
  // Avoid clobbering fields an upstream plugin may have registered
428
439
  // (e.g. an FK-derived relation with the same name).
429
440
  if (fields[fieldName]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphile-postgis",
3
- "version": "2.11.1",
3
+ "version": "2.11.3",
4
4
  "description": "PostGIS support for PostGraphile v5",
5
5
  "author": "Constructive <developers@constructive.io>",
6
6
  "homepage": "https://github.com/constructive-io/constructive",
@@ -46,7 +46,7 @@
46
46
  "graphile-build": "5.0.0",
47
47
  "graphile-build-pg": "5.0.0",
48
48
  "graphile-config": "1.0.0",
49
- "graphile-connection-filter": "^1.5.0",
49
+ "graphile-connection-filter": "^1.5.2",
50
50
  "graphql": "16.13.0",
51
51
  "pg-sql2": "5.0.0",
52
52
  "postgraphile": "5.0.0"
@@ -59,9 +59,9 @@
59
59
  "devDependencies": {
60
60
  "@types/geojson": "^7946.0.14",
61
61
  "@types/node": "^22.19.11",
62
- "graphile-test": "^4.9.0",
62
+ "graphile-test": "^4.9.1",
63
63
  "makage": "^0.3.0",
64
- "pgsql-test": "^4.9.0"
64
+ "pgsql-test": "^4.9.1"
65
65
  },
66
- "gitHead": "da90c33c7bde52c26611509c438fae42cec48b98"
66
+ "gitHead": "28734dd71a973b2fe296e8240c8f86c568b4292f"
67
67
  }
@@ -203,6 +203,11 @@ function collectSpatialRelations(build) {
203
203
  const pgRegistry = build.input?.pgRegistry;
204
204
  if (!pgRegistry)
205
205
  return [];
206
+ // Inflection is used to normalize user-supplied identifiers (the
207
+ // parametric arg name, e.g. `travel_distance` → `travelDistance`) into the
208
+ // GraphQL casing conventions. Fall back to identity if not available
209
+ // (e.g. when invoked from unit tests with a stub build).
210
+ const camelCase = build.inflection?.camelCase?.bind(build.inflection) ?? ((s) => s);
206
211
  const relations = [];
207
212
  for (const resource of Object.values(pgRegistry.pgResources)) {
208
213
  if (resource.parameters)
@@ -262,7 +267,7 @@ function collectSpatialRelations(build) {
262
267
  targetResource: target.resource,
263
268
  targetAttributeName: target.attributeName,
264
269
  operator: exports.OPERATOR_REGISTRY[parsed.operator],
265
- paramFieldName: parsed.paramName,
270
+ paramFieldName: parsed.paramName ? camelCase(parsed.paramName) : null,
266
271
  isSelfRelation,
267
272
  ownerPkAttributes,
268
273
  targetPkAttributes,
@@ -288,7 +293,10 @@ function collectSpatialRelations(build) {
288
293
  function spatialFilterTypeName(build, rel) {
289
294
  const { inflection } = build;
290
295
  const ownerTypeName = inflection.tableType(rel.ownerCodec);
291
- const rel0 = rel.relationName.charAt(0).toUpperCase() + rel.relationName.slice(1);
296
+ // Normalize the user-supplied relation name (which may be snake_case,
297
+ // kebab-case, or mixed) into PascalCase so the type name is consistent
298
+ // with every other generated GraphQL type name.
299
+ const rel0 = inflection.upperCamelCase(rel.relationName);
292
300
  return `${ownerTypeName}Spatial${rel0}Filter`;
293
301
  }
294
302
  /**
@@ -431,7 +439,10 @@ exports.PostgisSpatialRelationsPlugin = {
431
439
  const FilterType = build.getTypeByName(filterTypeName);
432
440
  if (!FilterType)
433
441
  continue;
434
- const fieldName = rel.relationName;
442
+ // Normalize the user-supplied relation name (which may be
443
+ // snake_case, kebab-case, or mixed) into camelCase so the GraphQL
444
+ // field name matches the casing of every other generated field.
445
+ const fieldName = inflection.camelCase(rel.relationName);
435
446
  // Avoid clobbering fields an upstream plugin may have registered
436
447
  // (e.g. an FK-derived relation with the same name).
437
448
  if (fields[fieldName]) {