Useful utility functions.
Useful utility functions.
(as-error-map t)
(as-error-map t more-data)
Converts an exception into an error map, including a :message key, plus
any additional keys and values via ex-data
.
In the second arity, a further map of values to be merged into the error map can be provided.
Converts an exception into an error map, including a :message key, plus any additional keys and values via `ex-data`. 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.
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.
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.
(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
.
Attaches stream handler functions to subscriptions. Replaces the :stream key inside subscription operations using the same logic as [[attach-resolvers]].
(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
:Type/name
:Type/name.argument
A simple 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., :Episode/NEW_HOPE
).
The final form is used to document an argument to a field (it does not make sense for enums).
Additionally, the Type
can be queries
, mutations
, or subscriptions
, in which case
the name
will be the name of the operation (e.g., :queries/episode
).
An exception is thrown if an element identified by a key does not exist.
See [[parse-docs]].
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` - `:Type/name` - `:Type/name.argument` A simple `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., `:Episode/NEW_HOPE`). The final form is used to document an argument to a field (it does not make sense for enums). Additionally, the `Type` can be `queries`, `mutations`, or `subscriptions`, in which case the `name` will be the name of the operation (e.g., `:queries/episode`). An exception is thrown if an element identified by a key does not exist. See [[parse-docs]].
(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.
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.
(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 :Type/field
.
Alternately, the key may be of the format :queries/name
(or :mutations/name
or
:subscriptions/name
).
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.
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 `:Type/field`. Alternately, the key may be of the format `:queries/name` (or `:mutations/name` or `:subscriptions/name`). 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.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close