Installations
npm install @graphile/postgis
Releases
Unable to fetch releases
Developer
graphile
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
18.14.0
NPM Version
9.3.1
Statistics
91 Stars
100 Commits
9 Forks
10 Watching
1 Branches
7 Contributors
Updated on 21 Nov 2024
Languages
TypeScript (97.99%)
Shell (1.17%)
JavaScript (0.84%)
Total Downloads
Cumulative downloads
Total Downloads
1,127,309
Last day
-66.7%
281
Compared to previous day
Last week
-20.1%
1,737
Compared to previous week
Last month
56.4%
6,931
Compared to previous month
Last year
-76%
84,191
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
@graphile/postgis
This is a PostGraphile schema plugin that provides support for the popular PostGIS spatial database system.
Create a PostgreSQL database with PostGIS columns, run PostGraphile with this plugin, and have a fully functional geospatial-aware GraphQL API for your database.
Roadmap
Work is ongoing, here's the plan:
- Read-only support for
geojson
field from all geography types (via a shared GraphQL interface) - Add GraphQL types for all the expected geography types (implementing this interface)
- Read-only support for determining the geometry sub-types of columns and exposing these directly (rather than the interface)
- Read-only support for
longitude
andlatitude
ongeography(POINT)
columns - Read-only support for viewing the list of
geometries
in ageography(GEOMETRYCOLLECTION)
- Read-only support for a list of points (
longitude
andlatitude
) ongeography(LINESTRING)
andgeography(POLYGON)
columns - Create/update/null support for
geography(POINT)
columns - Create/update/null support for
geography(LINESTRING)
andgeography(POLYGON)
columns - Integration with
postgraphile-plugin-connection-filter
to enable PostGIS specific filtering (via postgraphile-plugin-connection-filter-postgis) - Read-only support for computed attributes on
geography(LINESTRING)
andgeography(POLYGON)
, such asarea
,length
,perimeter
, andcentroid
- currently possible by adding a plugin and consuming the GeoJSON directly.
There are many, many other features that this plugin could support - if you have specific needs please get in touch!
Usage
This plugin requires PostGraphile v4.4.0 or higher to function correctly.
Add PostGIS to your database:
1CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
Load the plugin:
postgraphile --append-plugins @graphile/postgis
Querying and mutating
Using this table as example:
1CREATE TABLE data ( 2 id UUID PRIMARY KEY DEFAULT uuid_generate_v1mc(), 3 geom_point geometry(Point, 4326) default null 4);
In queries geom_point
is represented as type GeometryPoint
. Example:
1query { 2 allDatas { 3 nodes { 4 geomPoint { 5 geojson 6 srid 7 x 8 y 9 } 10 } 11 } 12}
In mutations geom_point
is represented as type GeoJSON
. Example:
1mutation ($id: UUID!, $geomPoint: GeoJSON!) { 2 updateDataById( 3 input: { 4 id: $id, 5 dataPatch: { 6 geomPoint: $geomPoint 7 } 8 } 9 ) { ... } 10}
with these variables:
1{ 2 "id": "0116254a-0146-11ea-8418-4f89d6596247", 3 "geomPoint": { 4 "type": "Point", 5 "coordinates": [8.5, 47.5] 6 } 7}
Beware of the fact that since 2016 the GeoJSON
spec expects the coordinates to be of SRID 4326/WGS84 (see https://tools.ietf.org/html/rfc7946#section-4). So adding a crs
field to the GeoJSON is deprecated. Thus since v3 PostGIS will be happy to receive above GeoJSON.
In earlier versions PostGIS expects a SRID to be passed. So the variables would be:
1{ 2 "id": "0116254a-0146-11ea-8418-4f89d6596247", 3 "geomPoint": { 4 "type": "Point", 5 "coordinates": [8.5, 47.5], 6 "crs": { 7 "type": "name", 8 "properties": { 9 "name": "urn:ogc:def:crs:EPSG::4326" 10 } 11 } 12 } 13}
Development
Contributions are extremely welcome! To get started, clone down this repo and then:
createdb graphile_test
export TEST_DATABASE_URL=postgres://localhost:5432/graphile_test
yarn
yarn dev
Note the development server runs at http://localhost:5123/graphiql
To run the tests:
yarn test
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 4/8 approved changesets -- score normalized to 5
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/graphile/.github/SECURITY.md:1
- Warn: no linked content found
- Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/graphile/.github/SECURITY.md:1
- Info: Found text in security policy: github.com/graphile/.github/SECURITY.md:1
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 27 are checked with a SAST tool
Reason
11 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-8cf7-32gw-wr33
- Warn: Project is vulnerable to: GHSA-hjrf-2m68-5959
- Warn: Project is vulnerable to: GHSA-qwph-4952-7xr6
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
Score
2.3
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More