# `AshGraphql`
[🔗](https://github.com/ash-project/ash_graphql/blob/v1.9.4/lib/ash_graphql.ex#L5)

AshGraphql is a GraphQL extension for the Ash framework.

For more information, see the [getting started guide](/documentation/tutorials/getting-started-with-graphql.md)

# `handle_errors`

```elixir
@spec handle_errors(
  result :: term(),
  resource :: Ash.Resource.t(),
  resolution :: Absinthe.Resolution.t(),
  opts :: Keyword.t()
) :: term()
```

Applies AshGraphql's error handling logic if the value is an `{:error, error}` tuple, otherwise returns the value

Useful for automatically handling errors in custom queries

## Options

- `domain`: The domain to use when loading the fields. Determined from the resource by default.

# `load_fields`

```elixir
@spec load_fields(
  input,
  Ash.Resource.t(),
  Absinthe.Resolution.t(),
  opts :: Keyword.t()
) ::
  {:ok, input} | {:error, term()}
when input: Ash.Resource.record() | [Ash.Resource.record()] | Ash.Page.page()
```

Use this to load any requested fields for a result when it is returned
from a custom resolver or mutation.

## Determining required fields

If you have a custom query/mutation that returns the record at a "path" in
the response, then specify the path. In the example below, `path` would be
`["record"]`. This is how we know what fields to load.

```elixir
query something() {
  result {
    record { # <- this is the instance
      id
      name
    }
  }
}
```

## Options

- `path`: The path to the record(s) in the response
- `domain`: The domain to use when loading the fields. Determined from the resource by default.
- `authorize?`: Whether to authorize access to fields. Defaults to the domain's setting (which defaults to `true`).
- `actor`: The actor to use when authorizing access to fields. Defaults to the actor in the resolution context.
- `tenant`: The tenant to use when authorizing access to fields. Defaults to the tenant in the resolution context.

# `load_fields_on_query`

```elixir
@spec load_fields_on_query(
  query :: Ash.Query.t() | Ash.Resource.t(),
  Absinthe.Resolution.t(),
  Keyword.t()
) :: Ash.Query.t()
```

The same as `load_fields/4`, but modifies the provided query to load the required fields.

This allows doing the loading in a single query rather than two separate queries.

# `subscription`
*macro* 

# `validate_response_metadata!`

Validates the `response_metadata` configuration at compile time.

Accepts:
- `nil` or `false` to disable
- An atom key to enable with default handler (e.g., `:metadata`)
- `{key, {module, function, args}}` tuple for a custom handler

Raises `ArgumentError` for invalid values.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
