Schema
SchemaBuilder
Section titled “SchemaBuilder”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)endThis 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.
How It Works
Section titled “How It Works”SchemaBuilder patches the schema’s execute, multiplex, and to_definition methods with lazy hooks. On the first call to any of these methods:
- All resources in
app/graphql/resources/are loaded and registered - Custom queries, mutations, and subscriptions in
app/graphql/are discovered - Types, fields, and connections are wired into the schema
- 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 endend