# `DCATR.ServiceData.Type`
[🔗](https://github.com/dcat-r/dcatr-ex/blob/v0.1.0/lib/dcatr/model/service_data/type.ex#L1)

Behaviour for defining custom service data catalogs with additional local graphs.

`DCATR.ServiceData` manages service-local graphs that are not part of the distributed repository
(e.g., configuration, working graphs, service-specific metadata). This behaviour enables
applications to create specialized service data catalogs with custom local graphs.

## Graph Structure

ServiceData contains:

- **manifest** - Service configuration (ServiceManifestGraph)
- **working_graphs** - Temporary/experimental graphs local to the service
- **system_graphs** - Service-level metadata and operational graphs

## Callbacks

- `c:system_graphs/1` - Returns service-level system graphs
- `c:working_graphs/1` - Returns service-local working graphs

Inherits from `DCATR.Directory.Type`:

- `c:DCATR.Directory.Type.graphs/1`, `c:DCATR.Directory.Type.directories/1`

Inherits from `DCATR.GraphResolver`:

- `c:DCATR.GraphResolver.resolve_graph_selector/2`

## Standard Selectors

- `:service_manifest` - Service configuration graph

## Usage

Custom service data types should `use DCATR.ServiceData.Type` and define a Grax schema
extending `DCATR.ServiceData`:

    defmodule MyApp.ServiceData do
      use DCATR.ServiceData.Type

      schema MyApp.NS.ServiceData < DCATR.ServiceData do
        link cache_graph: MyApp.NS.cache(), type: MyApp.CacheGraph
        link log_graph: MyApp.NS.log(), type: MyApp.LogGraph
      end

      @impl true
      def resolve_graph_selector(data, :cache), do: data.cache_graph
      def resolve_graph_selector(data, :log), do: data.log_graph
      def resolve_graph_selector(data, selector), do: super(data, selector)

      @impl true
      def system_graphs(data) do
        [data.cache_graph, data.log_graph | super(data)]
      end
    end

The module automatically provides delegating implementations of all callbacks
and convenience functions, all of which are overridable.

# `schema`

```elixir
@type schema() :: Grax.Schema.t()
```

# `t`

```elixir
@type t() :: module()
```

# `system_graphs`

```elixir
@callback system_graphs(service_data :: schema()) :: [DCATR.SystemGraph.t()]
```

Returns all service-local system graphs.

System graphs at the service level contain service-specific metadata, configuration,
or operational data.

Override to include additional service-local system graphs.

# `working_graphs`

```elixir
@callback working_graphs(service_data :: schema()) :: [DCATR.WorkingGraph.t()]
```

Returns all working graphs in the service data.

Working graphs are temporary or experimental graphs local to the service, not intended
for distribution with the repository.

Override to include additional working graphs specific to your service data type.

# `graphs`

```elixir
@spec graphs(schema()) :: [DCATR.Graph.t()]
```

Default implementation of `c:DCATR.Directory.Type.graphs/1` for service data.

Returns all graph members: manifest, working graphs, and system graphs.

# `resolve_graph_selector`

```elixir
@spec resolve_graph_selector(schema(), DCATR.GraphResolver.selector()) ::
  DCATR.Graph.t() | nil | :undefined
```

Default implementation of `c:DCATR.GraphResolver.resolve_graph_selector/2`.

Resolves service-data-specific selectors.

Supported selectors:

- `:service_manifest` - Service manifest graph

# `system_graphs`

```elixir
@spec system_graphs(schema()) :: [DCATR.SystemGraph.t()]
```

Default implementation of `c:system_graphs/1`.

Returns the `system_graphs` field.

# `working_graphs`

```elixir
@spec working_graphs(schema()) :: [DCATR.WorkingGraph.t()]
```

Default implementation of `c:working_graphs/1`.

Returns the `working_graphs` field.

---

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