Help us shape the future of Go! Take the 2026 Go Developer Survey

postgis

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package postgis is a built-in plugin exposing PostGIS spatial columns as a full GraphQL query surface.

Default generation already reads and writes spatial columns as GeoJSON (the core compiler handles the GeoJSON scalar). This plugin adds everything built on top of that:

  • spatial filters: every geometry/geography column gets a GeometryFilterOps operand set covering bounding-box operators (bboxIntersects/&&, bboxContains/~, bboxContainedBy/@), the DE-9IM predicates (intersects, contains, within, covers, crosses, touches, overlaps, equals, disjoint, containsProperly, coveredBy), and radius search (dwithin/beyond). Bounding-box and dwithin operators are GiST-index-usable, which is what keeps viewport and "near me" queries fast on large tables.

  • derived accessors: each spatial column gains sibling fields for the scalar properties PostGIS can compute in the same statement — <field>Area, <field>Length, <field>Perimeter, <field>Centroid, <field>Envelope, <field>Srid, <field>GeometryType, <field>IsValid.

  • projection arguments: spatial fields accept transform: (reproject to an SRID) and simplify: (ST_SimplifyPreserveTopology tolerance), so clients can pull web-mercator or low-vertex geometry without a second query.

  • distance ordering: <COLUMN>_DISTANCE_ASC/_DESC orderBy values plus a `near:` argument on list and connection fields, compiled to the index-assisted KNN operator (<->).

Geometry and geography are both supported. They share the operator vocabulary but differ in units: geography measures in metres, geometry in SRID units. dwithin takes a `useSpheroid` flag so lat/lon data stored as plain geometry can still be searched in metres.

Like advanced-filters, the plugin only adds schema surface plus catalog bindings; the compiler reads the bindings and stays inert when they are absent, so disabling the plugin (plugins.disabled: postgis) removes the surface completely while plain GeoJSON read/write keeps working.

Per-object control follows the same smart-comment conventions as the rest of the codebase: "@omit filter" / "@omit order" on a spatial column skips its filter / ordering surface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin implements the SchemaHook adding the spatial surface.

func New

func New(settings map[string]any) *Plugin

New builds the plugin from its `plugins.settings.postgis` map.

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Priority

func (p *Plugin) Priority() int

Priority 160 places the plugin just after advanced-filters (150), so the filter inputs it extends already exist and relation filters are in place.

func (*Plugin) TransformSchema

func (p *Plugin) TransformSchema(_ context.Context, b *schema.Builder) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL