Root Object Names

Top-level query, mutation, and subscription operations are represented in Lacinia as fields on special objects. These objects are the “operation root objects”. The default names of these objects are Query, Mutation, and Subscription.

When compiling an input schema, these objects will be created if they do not already exist.

The :roots key of the input schema is used to override the default names. Inside :roots, you may specify keys :query, :mutation, or :subscription, with the value being the name of the corresponding object. There is rarely a need to rename the objects from default values, however.

If the objects already exist, then any fields on the objects are automatically available operations. In the larger GraphQL world (beyond Lacinia), this is the typical way of defining operations.

Beyond that, the operations from the :queries, :mutations, and :subscriptions maps of the input schema will be merged into the fields of the corresponding root object; this is supported, but not prefered.

Name collisions are not allowed; a schema compile exception is thrown if an operation (via :queries, etc.) conflicts with a field of the corresponding root object.


It is allowed for the root type to be a union. This can be a handy way to organize many different operations.

In this case, Lacinia creates a new object and merges the fields of the members of the union, along with any operations from the input schema.

Again, the field names must not conflict.

The new object becomes the root operation object.