I'm trying to use the graphql-geojson library in an Apollo/Express app to serve GeoJSON responses.
The library provides the resolvers but I haven't found a way to add the types to my schema definition without writing them out by hand. And even then that hasn't proven that simple.
Another custom type, Date from graphql-date, I can just declare in the schema as a custom scalar:
const typeDefs: DocumentNode = gql`
scalar Date
scalar PointObject
type Station {
id: ID!
name: String!
geom: PointObject
created: Date!
}
...
}
However, declaring PointObject as scalar allows you to get the full GeoJSON (which is OK) but results in errors:
"GraphQLError: Field \"geom\" must not have a selection since type \"GeoJSONPoint\" has no subfields."
when you try to return a sub-selection of geom
, e.g.:
{
stations {
id
name
geom {
coordinates
}
}
}
Is there a way merge the types provided by the library with my schema?