RiddlerGraphQL.Types.JSON (RiddlerGraphQL v0.1.0)

Copy Markdown View Source

The RiddlerJSON scalar: a JSON value, carried unchanged and coerced in neither direction.

A host imports it into its own schema with import_types RiddlerGraphQL.Types.JSON. Its Absinthe identifier is :riddler_json, so it sits beside a host scalar of its own named JSON.

As output, the value a resolver returns is the value the client reads: an object, a list, a string, a number, a boolean or null, with nothing parsed, stringified or renamed on the way.

As input, a literal or a variable is read as the JSON value it writes: an object's keys stay as the client spelt them, a list inside an object keeps its order, and a string stays a string even when it reads as JSON. Absinthe hands the scalar an object, a string, a number, a boolean or null at the top of an argument, and refuses a list there as an invalid value before the scalar is asked. An enum literal, which JSON cannot write, is refused as an invalid value too.