/

hasura-header-illustration

Now in GraphQL Engine: Native support for PostGIS topology operators

A lot of the developers in the Hasura GraphQL Engine community use PostGIS, the popular spatial database extension for Postgres, for their apps, and it was only natural for them to expect first-class support for PostGIS topology operators like ST_Contains, ST_Within, ST_DWithin, etc. in Hasura’s GraphQL API. We are very pleased to announce the availability of native support for these operators as boolean GraphQL operators!

Using PostGIS topology operators in GraphQL

Let’s say you want to fetch a list of popular landmarks within a district/borough. In your database schema you have a table called  landmarks (a list of popular locations, with a column of type geometry called location) and you need to search landmarks that are within a polygon (how you may model a district/borough). This is how you can now implement this search in a query using PostGIS’ ST_Within operator as a boolean GraphQL operator in the where argument:

You’ll have to pass the variable as JSON (GeoJSON ) representation of geometry values as shown below:

You can use these operators in subscriptions and mutations too.

List of supported PostGIS topology operators

The following is a list of all supported topology operators:

We are all ears!

We are huge fans of the PostGIS extension and very excited to contribute to the experience for developers using both PostGIS  and GraphQL Engine. We'd love to hear your thoughts on this release - please do try it out and let us know how we can further improve our PostGIS support.

Blog
23 Jan, 2019
Email
Subscribe to stay up-to-date on all things Hasura. One newsletter, once a month.
Loading...
v3-pattern
Accelerate development and data access with radically reduced complexity.