Skip to content

Latest commit

 

History

History
68 lines (53 loc) · 1.11 KB

README.md

File metadata and controls

68 lines (53 loc) · 1.11 KB

graphql-geojson-scalar-types

GraphQL schema scalar types for GeoJSON. Based on GeoJSON Validation.

Installation

npm i graphql-geojson-scalar-types

or

yarn add graphql-geojson-scalar-types

Usage

import { GraphQLObjectType, GraphQLSchema } from 'graphql'
import { Point } from 'graphql-geojson-scalar-types'

export default new GraphQLSchema({
  query: new GraphQLObjectType({
    name: 'Query',
    fields: () => ({
      point: {
        type: Point,
        resolve: () => ({
          type: 'Point',
          coordinates: [-105.01621, 39.57422],
        }),
      },
      pointInvalid: {
        type: Point,
        resolve: () => ({
          type: 'Invalid',
          coordinates: [-105.01621, 39.57422],
        }),
      },
    }),
  }),
})

Then you can query it like this:

query {
  point
  pointInvalid
}

Demo

npm run demo

or

yarn demo

An example GraphQL server implementation is available here: demo