Commit 16ad9f9
committed
feat(graphile-postgis): PostgisSpatialRelationsPlugin — cross-table spatial filters via @spatialRelation smart tags
Adds PostgisSpatialRelationsPlugin: a smart-tag-driven plugin that
synthesises cross-table and self-relation filter fields whose join
predicate is a PostGIS spatial function (ST_Contains, ST_DWithin, …).
Tag grammar:
COMMENT ON COLUMN owner.col IS
E'@spatialRelation <name> <table>.<col> <operator> [<param>]';
Supported operators (v1, PG-native snake_case):
2-arg: st_contains, st_within, st_covers, st_coveredby,
st_intersects, st_equals, st_bbox_intersects
3-arg: st_dwithin (parametric distance, meters for geography,
SRID units for geometry)
Filter shapes:
2-arg: { county: { some: { name: { eq: 'California County' } } } }
dwithin: { nearbyClinic: { distance: 5000, some: {...} } }
Features:
- Emits EXISTS (…) subqueries with ST_<op>(target, owner) join
predicate, reusing connection-filter's some/every/none plumbing.
- Auto self-join exclusion for self-relations (single- or composite-PK).
- GIST-index warning at schema build time when the target column
has no GIST index.
- pg_proc validation: operators must resolve against the PostGIS
schema at build time.
- Works with non-public PostGIS schemas (uses sql.identifier, not
literals).
Tests:
- 31 unit tests: tag parsing, registry, collection, validation
errors (graphile-postgis/__tests__/spatial-relations.test.ts).
- E2E tests via ORM with counties + telemedicine_clinics fixture
(orm-test/__tests__/postgis-spatial-relations.test.ts).
- Seed adds counties + telemedicine_clinics tables with four
@spatialRelation tags exercising cross-table and self-relation
paths.
Refs: constructive-io/constructive-planning#7281 parent 1281a53 commit 16ad9f9
9 files changed
Lines changed: 1913 additions & 3 deletions
File tree
- graphile/graphile-postgis
- __tests__
- src
- plugins
- graphql/orm-test
- __fixtures__/seed
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
45 | 127 | | |
46 | 128 | | |
47 | 129 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
14 | 19 | | |
15 | 20 | | |
16 | 21 | | |
| |||
0 commit comments