Registry / database / graphql-geojson

graphql-geojson

JSON →
library1.0.0jsnpmunverified

GraphQL schema object types for GeoJSON (v1.0.0). Provides GraphQL types for representing GeoJSON geometry objects (Point, LineString, Polygon, etc.) within a GraphQL schema. It integrates seamlessly with the reference GraphQL.js implementation. The library is mature and stable, but note that it is deprecated in favor of graphql-geojson-scalar-types for simpler scalar-based approach. Release cadence is low; no updates since 2017.

npm install graphql-geojson
INSTALL
IMPORT
SIG · GRAPHQL-GEOJSON
G
graphql-geojson
databasejavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PointObject
import { PointObject } from 'graphql-geojson'
const graphqlGeojson = require('graphql-geojson'); const PointObject = graphqlGeojson.PointObject;
ESM import is preferred; the package also supports CJS require.
LineStringObject
import { LineStringObject } from 'graphql-geojson'
Same pattern for all geometry types.
GeoJSONInterface
import { GeoJSONInterface } from 'graphql-geojson'
Used to define a union or interface for any GeoJSON type.

Shows how to define a GraphQL schema with a GeoJSON Point field using graphql-geojson.

import { GraphQLObjectType, GraphQLSchema } from 'graphql'; import { PointObject } from 'graphql-geojson'; export default new GraphQLSchema({ query: new GraphQLObjectType({ name: 'Query', fields: () => ({ point: { type: PointObject, resolve: () => ({ type: 'Point', coordinates: [-105.01621, 39.57422], }), }, }), }), }); // Run with: node -r esm server.js
Debug
Known issues
deprecatedPackage is deprecated. Use graphql-geojson-scalar-types for a scalar-based approach instead of object types.
fix
Replace with graphql-geojson-scalar-types or switch to custom scalar types.
affects: >=1.0.0
gotchagraphql-geojson defines object types (e.g., PointObject) that require explicit resolves for nested fields. This can lead to large schemas and complex resolvers.
fix
Consider using graphql-geojson-scalar-types which as a single custom scalar.
affects: >=1.0.0
gotchaThe library does not include a GeoJSON validation. Invalid input coordinates will be passed through without error.
fix
Manually validate GeoJSON inputs before storing or processing.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'graphql-geojson'
Package not installed or missing from node_modules
fix
Run npm install graphql-geojson (and graphql as peer dep) from the project root.
TypeError: Cannot read properties of undefined (reading 'PointObject')
Incorrect import path or using a build tool that doesn't resolve the proper entry
fix
Use a named import: import { PointObject } from 'graphql-geojson'
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
graphqlrequiredpeer dependency; GraphQL types are required for schema definitions
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
graphql-geojson — npm install graphql-geojson · libregistry