hasura / hasura/graphql-engine
Support relationships based on built-in functions (i.e. st_within)
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Component
v/3-engine
v/3-ndc-postgres
### Is your proposal related to a problem?
We manage a large number of tables with entries related through geometry columns instead of foreign keys. For instance, a table of buildings with geometries and tables like districts or housing zones with corresponding geometries. Given the frequent changes in zoning and the high number of relationships, calculating and storing foreign keys is impractical.
### Describe the solution you'd like
It would be useful to define relationships via built-in functions like ST_Within instead of just foreign key mapping.
```yml
kind: Relationship
version: v1
definition:
name: buildings
sourceType: District
target:
model:
name: Buildings
relationshipType: Array
mapping:
- function:
functionName: st_within
arguments:
- target:
fieldPath:
- fieldName: geometry
- source:
fieldPath:
- fieldName: geometry
```
### Describe alternatives you've considered
Creating native operations and mapping them to commands, but this approach is impractical due to the large number of operations required just to enable data joins.
Contributor guide
Assessment
This issue has not been assessed yet.