import * as GraphQL from "graphql" ; type Maybe < T > = null | undefined | T ; export default function makeGeoJSONType ( graphql , name = "GeoJSON" ) { const Kind = graphql . Kind ; const GraphQLScalarType = graphql . GraphQLScalarType ; function identity < T > ( value ) { return value ; } function parseLiteral ( ast , variables ) { switch ( ast . kind ) { case Kind . STRING : case Kind . BOOLEAN : return ast . value ; case Kind . INT : case Kind . FLOAT : return parseFloat ( ast . value ) ; case Kind . OBJECT : { const value = Object . create ( null ) ; ast . fields . forEach ( field => { value [ field . name . value ] = parseLiteral ( field . value , variables ) ; } ) ; return value ; } case Kind . LIST : return ast . values . map ( n => parseLiteral ( n , variables ) ) ; case Kind . NULL : return null ; case Kind . VARIABLE : { const variableName = ast . name . value ; return variables ? variables [ variableName ] : undefined ; } default : return undefined ; } } return new GraphQLScalarType ( { name , description : `The \`${ name }\` scalar type represents GeoJSON values as specified by` + "[RFC 7946](https://tools.ietf.org/html/rfc7946)." , serialize : identity , parseValue : identity , parseLiteral , } ) ; }