SPI Services

The GraphQL viewer defines a couple of services that are intended to act as SPI hooks for more sophisticated implementations. The viewer does provide default implementations.

UserMementoProvider

The UserMementoProvider SPI is used to obtain the UserMemento — in other words the identity — of the client executing the API.

The default (fallback) implementation simply uses a hard-coded value taken from the configuration:

In a production app, you might instead want to infer the client identity by hooking into the HTTP request parameters. See the Spring documentation on securing the GraphQL endpoint and Context Propagation for more details.

ScalarMarshaller

The ScalarMarshaller SPI provides an extension point for the marshalling of a given scalar value (eg an int or a date) between its Java and GraphQL datatype. The framework provides a number of default implementations, and these use a number of configuration properties:

The default implementations can be overridden if necessary by providing an equivalent implementation with an earlier @Priority. Additional scalar datatypes can be supporting by providing additional implementations.