Problem
Ruru's variable editor (built on @graphiql/react → monaco-graphql → graphql-language-service) flags any custom scalar that holds an object or array as invalid, e.g. for @graphile/postgis's GeoJSON scalar:
{ "type": "Point", "coordinates": [9.5, 51.3] }
produces:
Incorrect type. Expected one of string, number, boolean, integer.
in the variable editor, even though the request executes fine server-side. This affects any plugin author whose input/output types include a custom JSON-like scalar (GeoJSON, arbitrary JSON, etc.), so it is not specific to postgis.
Root cause
Traced fully in graphql/graphiql#4447. Short version: graphql-language-service and monaco-graphql already support overriding the JSON Schema used for a given scalar name (customScalarSchemas), but @graphiql/react - which Ruru renders directly - never exposes this as a prop. I have a patch for @graphiql/react ready: graphql/graphiql#4448.
What Ruru would need, once that lands
Once @graphiql/react accepts customScalarSchemas and a release is out:
- Add
customScalarSchemas to RuruProps (ruru-types) and RuruClientConfig/RuruConfig (ruru), following the same Pick<GraphiQLProps, ...> pattern already used for editorTheme, initialVariables, etc.
- Thread it down to wherever the
<GraphiQL>/<GraphiQLProvider> instance gets mounted, so it can be set via graphile.config.ts.
- Bump the
@graphiql/react dependency to the release containing the new prop.
Happy to send this as a PR too once the upstream piece is merged and released! Opening this as a tracking issue in the meantime since it's blocked on that.
Motivating use case
@graphile/postgis's GeoJSON scalar (see graphile/postgis#66) is exactly this shape: input/output type for geometry/geography columns, holds arbitrary GeoJSON objects.
Problem
Ruru's variable editor (built on
@graphiql/react→monaco-graphql→graphql-language-service) flags any custom scalar that holds an object or array as invalid, e.g. for@graphile/postgis'sGeoJSONscalar:{ "type": "Point", "coordinates": [9.5, 51.3] }produces:
in the variable editor, even though the request executes fine server-side. This affects any plugin author whose input/output types include a custom JSON-like scalar (GeoJSON, arbitrary JSON, etc.), so it is not specific to postgis.
Root cause
Traced fully in graphql/graphiql#4447. Short version:
graphql-language-serviceandmonaco-graphqlalready support overriding the JSON Schema used for a given scalar name (customScalarSchemas), but@graphiql/react- which Ruru renders directly - never exposes this as a prop. I have a patch for@graphiql/reactready: graphql/graphiql#4448.What Ruru would need, once that lands
Once
@graphiql/reactacceptscustomScalarSchemasand a release is out:customScalarSchemastoRuruProps(ruru-types) andRuruClientConfig/RuruConfig(ruru), following the samePick<GraphiQLProps, ...>pattern already used foreditorTheme,initialVariables, etc.<GraphiQL>/<GraphiQLProvider>instance gets mounted, so it can be set viagraphile.config.ts.@graphiql/reactdependency to the release containing the new prop.Happy to send this as a PR too once the upstream piece is merged and released! Opening this as a tracking issue in the meantime since it's blocked on that.
Motivating use case
@graphile/postgis'sGeoJSONscalar (see graphile/postgis#66) is exactly this shape: input/output type for geometry/geography columns, holds arbitrary GeoJSON objects.