> ## Documentation Index
> Fetch the complete documentation index at: https://fastql.vachagan.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Operations and schema

> Compose query, mutation, and subscription roots into a schema.

Operation decorators use the same class and field model as `@Type`.

```python theme={null}
from fastql import Field, Mutation, Query, Schema, Subscription


@Query(name="Query")
class QueryRoot:
    version: str = "1.0"


@Mutation(name="Mutation")
class MutationRoot:
    @Field
    def rename_user(self, id: str, name: str) -> bool:
        return True


@Subscription(name="Subscription")
class SubscriptionRoot:
    status: str = "idle"


schema = Schema(
    query=QueryRoot,
    mutation=MutationRoot,
    subscription=SubscriptionRoot,
)
```

`Schema(...)` compiles decorated Python root classes automatically. `build_schema(...)`
provides the equivalent functional API and accepts additional named types, a registry,
and `SchemaConfig`.

<Note>
  Subscription execution and the streaming subscription transports
  (`graphql-transport-ws`, SSE, and `multipart/mixed`) are implemented — see
  [Subscriptions](/protocol/subscriptions). The bundled development server does not
  host them; run subscriptions through a production [framework adapter](/integrations/overview).
</Note>
