Useful utility functions.
added in 0.16.0
(as-error-map t more-data)
Converts an exception into an error map, including a :message key, plus any additional keys and values via
In the second arity, a further map of values to be merged into the error map can be provided.
(attach-resolvers schema resolver-m)
Given a GraphQL schema and a map of keywords to resolver fns, replace each placeholder keyword in the schema with the actual resolver fn.
resolver-m is a map from of resolver functions and resolver function factories. The keys are usually keywords, but may be any value including string or symbol.
When the value in the :resolve key is a simjple value, it is simply replaced with the corresponding resolver function from resolver-m.
Alternately, the :resolve value may be a seq, indicating a resolver factory.
The first value in the seq is used to select the resolver factory function, which is then invoked, via
apply, with the remaining values in the seq.
(attach-scalar-transformers schema transform-m)
Given a GraphQL schema, attaches functions in the transform-m map to the schema.
Inside each scalar definition, the :parse and :serialize keys are replaced with values from the transform-m map.
In the initial schema, use a keyword for the :parse and :serialize keys, then provide a corresponding value in transform-m.
added in 0.19.0
(attach-streamers schema streamer-map)
Attaches stream handler functions to subscriptions.
Replaces the :stream key inside subscription operations using the same logic as attach-resolvers.
added in 0.27.0
(inject-descriptions schema documentation)
Injects documentation into a schema, as
:description keys on various elements within the schema.
The documentation map keys are keywords with a particular structure, and the values are formatted Markdown strings.
The keys are one of the following forms:
Type will document an object, input object, interface, union, or enum.
The second form is used to document a field of an object, input object, or interface, or to document a specific value of an enum (e.g.,
The final form is used to document an argument to a field (it does not make sense for enums).
Type can be
subscriptions, in which case the
name will be the name of the operation (e.g.,
An exception is thrown if an element identified by a key does not exist.
added in 0.36.0
(inject-enum-transformers schema transform-m)
Given a GraphQL schema, injects transformers for enums into the schema.
transform-m maps from the scalar name (a keyword) to a map with keys :parse and/or :serialize; these are applied to the Enum.
Each enum must exist, or an exception is thrown.
added in 0.27.0
(inject-resolvers schema resolvers)
Adds resolvers to the schema. The resolvers map is a map of keywords to field resolvers (as functions, or FieldResolver instances).
The key identifies where the resolver should be added, in the form
Alternately, the key may be of the format
Throws an exception if the target of the resolver can’t be found.
In many cases, this is a full replacement for attach-resolvers, but the two functions can also be used in conjunction with each other.
added in 0.37.0
(inject-scalar-transformers schema transform-m)
Given a GraphQL schema, injects transformers for scalars into the schema.
transform-m maps from the scalar name (a keyword) to a map with keys :parse and :serialize; these are applied to the Enum.
Each scalar must exist, or an exception is thrown.
added in 0.37.0
(inject-streamers schema streamers)
As inject-resolvers but the updated key is :stream, thereby supplying a subscription streamer function.