Skip to content

Schema

The generated schema uses lazy configuration. Quail hooks into execute, multiplex, and to_definition so resources are loaded and wired up on first use:

class AppSchema < GraphQL::Schema
Quail::SchemaBuilder.call(self)
end

This means your schema class stays minimal — Quail discovers all registered resources, custom queries, mutations, and subscriptions at runtime and attaches them to the schema automatically.

SchemaBuilder patches the schema’s execute, multiplex, and to_definition methods with lazy hooks. On the first call to any of these methods:

  1. All resources in app/graphql/resources/ are loaded and registered
  2. Custom queries, mutations, and subscriptions in app/graphql/ are discovered
  3. Types, fields, and connections are wired into the schema
  4. The lazy hooks remove themselves — subsequent calls go directly to graphql-ruby

This lazy approach means your Rails app boots quickly even with many resources, since schema assembly is deferred until the first GraphQL request.

Custom Subscriptions Alongside Auto-Generated Ones

Section titled “Custom Subscriptions Alongside Auto-Generated Ones”

You can pass a block to SchemaBuilder.call to add custom subscription fields alongside the auto-generated ones:

class AppSchema < GraphQL::Schema
Quail::SchemaBuilder.call(self) do |schema|
# Add custom subscription fields alongside auto-generated ones
end
end