Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/enniel/graphql-geojson-scalar-types
https://github.com/enniel/graphql-geojson-scalar-types
geojson graphql
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/enniel/graphql-geojson-scalar-types
- Owner: enniel
- License: mit
- Created: 2017-11-03T07:17:43.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T02:23:35.000Z (almost 2 years ago)
- Last Synced: 2024-10-05T22:17:42.430Z (about 1 month ago)
- Topics: geojson, graphql
- Language: TypeScript
- Size: 178 KB
- Stars: 15
- Watchers: 4
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# graphql-geojson-scalar-types
GraphQL schema scalar types for GeoJSON. Based on [GeoJSON Validation](https://gitlab.com/mjbecze/GeoJSON-Validation).
## Installation
```bash
npm i graphql-geojson-scalar-types
```or
```bash
yarn add graphql-geojson-scalar-types
```## Usage
```ts
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:
```graphql
query {
point
pointInvalid
}
```## Demo
```bash
npm run demo
```or
```bash
yarn demo
```An example GraphQL server implementation is available here:
[demo](https://github.com/enniel/graphql-geojson-scalar-types/tree/master/demo)