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:
-
causeway.viewer.graphql.authentication.fallback.username
The username of the client assumed to be making the GraphQL call.
-
causeway.viewer.graphql.authentication.fallback.roles
Corresponding roles. May or may not be used, depending upon the security configuration. (For example, if SecMan is in use, then the roles are defined by SecMan itself and this config property is ignored).
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:
-
causeway.viewer.graphql.scalar-marshaller.local-date-format.
GraphQL does not have a built-in date datatype, and so must be represented as strings. This configuration property define the format of such a string for a local date.
The default for local dates is "yyyy-MM-dd"
-
causeway.viewer.graphql.scalar-marshaller.zoned-date-time-format
GraphQL does not have a built-in date/time datatype, and so must be represented as strings. This configuration property define the format of such a string for a zoned date time.
The default for a zoned date time is "yyyy-MM-dd HH:mm:ss z".
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.