Skip to content

Ruru: expose customScalarSchemas so custom scalars aren't flagged as invalid in the variable editor #3117

Description

@dargmuesli

Problem

Ruru's variable editor (built on @graphiql/reactmonaco-graphqlgraphql-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.

Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions