As a result, we defined the scalar type GeoJSON instead of the type of the object. This would allow us to perform rigorous checks against the GeoJSON specification. So far, just to keep us moving, we have defined a (not fully implemented) custom type of GeoJSON:
var GeoJSON = new GraphQLScalarType({ name: 'GeoJSON', serialize: (value) => { // console.log('serialize value', value); return value; }, parseValue: (value) => { // console.log('parseValue value', value); return value; }, parseLiteral: (ast) => { // console.log('parseLiteral ast', ast); return ast.value; } });
... which allows us to use it as follows:
var Geometry = new GraphQLObjectType({ name: 'Geometry', fields: () => ({ id: globalIdField('Geometry'), geojson: { type: GeoJSON, }, }, };
You can use this strategy to define a custom type to represent an array of arrays or define a custom type to represent only nested arrays, and then use new GraphQLList(CoordinatesType) , etc. It depends on the data you are modeling.
source share