Changes have started to bring Lacinia into compliance with the June 2018 version of the GraphQL specification.
Lacinia now supports block strings (via """
) in query and schema documents.
In addition, descriptions are now supported inside schema documents; a string (or block string) before an element in the schema becomes the documentation for that element.
The error maps inside the :error
key are now structured according to the June 2018 spec;
the top level keys are :message
, :locations
, and :path
, and
:extensions
(which contains any other keys in the error map supplied
by the field resolver).
The behavior of the :scalars
option to com.walmartlabs.lacina.parser.schema/parse-schema
has changed slightly; the values provided are now merged with any scalar
data defined in the schema document.
Previously, the supplied value overwrote what was parsed.
Removed a potential race condition related to asynchronous field resolvers.
A change to how GraphQL schema documentation is attached.
Previously, arguments were refered to as :MyType.my_field/arg_name
but with this release, we've changed it to :MyType/my_field.arg_name
.
It is now possible, when parsing a schema from SDL via
com.walmartlabs.lacinia.parser.schema/parse-schema
, to
attach descriptions to interfaces, enums, scalars, and unions.
Previously, only objects and input objects could have descriptions attached.
New function com.walmartlabs.lacinia.util/inject-resolvers
is an alternate way
to attach resolvers to a schema.
It is now possible to combine external documentation, from a Markdown file,
into an EDN schema.
See com.walmartlabs.lacinia.parser.docs/parse-docs
and
com.walmartlabs.lacinia.util/inject-descriptions
.
Lacinia now supports the :roots
key in the input schema, which makes
it possible to define query, mutation, or subscription operations
in terms of the fields of an explicitly named object in the schema.
This aligns Lacinia better with other implementations of GraphQL.
Lacinia is now based on Clojure 1.9, though it can also be used with Clojure 1.8.
Added the com.walmartlabs.lacinia.parser/summarize-query
function,
which is used to summarize a query without distractions such as
aliases and field arguments. This is used to group similar
queries together when doing performance analysis.
Query parsing logic has been rewritten entirely, for performance and maintenance reasons. As a side-effect, location information for query errors is more accurate.
Enum validation has changed: field resolvers may now return a keyword, symbol, or string. Internally, the value is converted to a keyword before being added to the response map.
However, field resolvers that return an invalid value for an enum field results in a thrown exception: previously, this was handled as a field error.
It is now possible to mark fields (including operations) and enum values as deprecated.
Compiled schemas now print and pretty-print as #CompiledSchema<>
.
Added the FieldResolver protocol that allows a Clojure record, such as a Component, to act as a field resolver.
Field resolvers for enum types are now required to return a keyword, and that keyword must match one of the values defined for the enum. Previously, Lacinia failed to perform any checks in this case, which could result in invalid data present in the result map.
Added com.walmartlabs.lacina.resolve/wrap-resolver-result
which makes it easier
to wrap an existing resolver function, but safely manipulate the resolved
value.
Fixes a bug that prevented operation names from working when a query defined only a single operation.
Previously, the reserved words 'query', 'mutation', and 'subscription' could not be used as the name of an operation, variable, field, etc. The grammar and parser have been changed to allow this.
Lacinia has a new API for parsing a GraphQL schema as an alternative to using Lacinia's EDN format.
Simplified a clojure.spec to prevent a potential runtime error
Could not locate clojure/test/check/generators__init.class or clojure/test/check/generators.clj on classpath
.
This would occur when the :default-field-resolver option was specified, and org.clojure/test.check was
not on the classpath (it is a side-effect of having com.walmartlabs.lacina/compile
be always instrumented).
A number of small optimizations have been made, shaving a few milliseconds off selections on very large lists.
Object fields and field arguments may now inherit their description from corresponding fields and field arguments of an implemented interface.
There is now a mechanism to allow a ResolverResult callback to be invoked in a application-provided executor or thread pool.
Lacinia now includes support for GraphQL subscriptions.
Lacinia no longer catches and reports exceptions inside field resolvers.
It is now possible for a field resolver to modify the application context passed to all nested field resolvers (at any depth).
The :decorator option to com.walmartlabs.lacinia.schema/compile
has been
removed. This is a feature, added in 0.17.0, that can be better implemented
in application code.
The callback provided to the
com.walmartlabs.lacinia.resolve/on-deliver!
protocol method has
changed to only accept a single value.
Previously, the callback received a resolved value and an nilable error map.
This method is not intended for use in application code.
The com.walmartlabs.lacinia.schema/compile
function is now always instrumented.
This means that non-conforming schemas will fail with a spec verification exception.
com.walmartlabs.lacinia.schema/tag-with-type
now uses metadata in the majority of cases
(as it did in 0.16.0), resorting to a wrapper type only when
the value is a Java object that doesn't support metadata.
Queries with repeated identical fields (same alias and arguments) will now be merged together along with their subselections.
Fixed Selections API functions throwing a NullPointerException on Introspective meta fields.
Upgraded to clojure-future-spec
1.9.0-alpha17.
Lacinia now better implements the specification, in terms of parsing and serializing scalars.
The default mapping from field name to field resolver has simplified;
it is now a direct mapping, without converting underscores to dashes.
The old behavior is still available via an option to
com.walmartlabs.lacinia.schema/compile
.
The function com.walmartlabs.lacinia.schema/tag-with-type
has changed; it
now returns a special wrapper value (rather than the same value with
different metadata). This is to allow resolved values that do not
support metadata, such as Java objects.
The related function com.walmartlabs.lacinia.schema/type-tag
has been removed.
Please update your applications carefully.
compile
now has a new option, :decorator
.
The decorator is a callback applied to all non-default field resolvers.
The primary use case is to adapt the return value of a field resolver,
for example, from a core.async channel to a Lacinia ResolverResult.
New function: com.walmartlabs.lacinia.parser/operations
: extracts
from a parsed query the type (mutation or query) and the set of
operations.
Several new experimental functions were added to com.walmartlabs.lacinia.executor
to
expose details about the selections tree; these functions can be invoked
from a field resolver to preview what fields will be selected below
the field.
The function com.walmartlabs.lacinia.schema/as-conformer
is now public.
New function com.walmartlabs.lacinia/execute-parsed-query-async
.
Lacinia can now, optionally, collect timing information about
field resolver functions. This information is returned in the
:extensions :timings
key of the response.
Field resolvers can now operate synchronously or asynchronously.
This release fleshes out the Lacinia type system to be fully compliant with the
GraphQL type system.
Previously, there were significant limitations when combining list
and non-null
modifiers on types.
The internal representation of enum values has changed from String to Keyword. You will now see a Keyword, not a String, supplied as the value of an enum-typed argument or variable. You may need to make small changes to your field resolvers.
This release adds some very small performance improvements.
Field resolver functions may now return sets (where the schema type is a list). Previously this generated a runtime error.
There is a change to the signature of the
com.walmartlabs.lacinia.executor/execute-query
function
that will not affect the majority of users.
We have removed an unused dependency on org.clojure/tools.macro
.
And, of course, smaller fixes and improvements to the documentation.
Lucky 13 is our first publicly available version of Lacinia. It is still alpha and still subject to change, however.