# `Gno.Service`
[🔗](https://github.com/rdf-elixir/gno/blob/v0.1.0/lib/gno/service.ex#L1)

A `DCATR.Service` for SPARQL triple stores.

A service combines the structural model from `DCATR.Service` with Gno-specific
operational concerns:

- `store` - a `Gno.Store` backend providing the SPARQL triple store connection
- `commit_operation` - a `Gno.CommitOperation` defining the middleware pipeline
  and commit workflow

Services are typically loaded from RDF manifest files via `Gno.Manifest` and
then used with the functions in the top-level `Gno` module. Repository
initialization is handled by `Gno.Service.Setup`.

## Graph Selectors

Many operations accept a graph selector (via the `:graph` option or
`graph_name/2`) that is resolved to a concrete graph IRI. Built-in
selectors include:

- `:default` — the default graph of the RDF dataset
- `:primary` — the primary data graph designated in the repository manifest
- `:repo_manifest` — the repository manifest graph
- `:service` — all service graphs (for bulk operations like `drop/2`)

Custom selectors can be added by overriding `c:DCATR.GraphResolver.resolve_graph_selector/2`.

# `t`

```elixir
@type t() :: %Gno.Service{
  __additional_statements__: term(),
  __id__: term(),
  commit_operation: term(),
  graph_names: term(),
  graph_names_by_id: term(),
  local_data: term(),
  repository: term(),
  store: term(),
  use_primary_as_default: term()
}
```

# `build`

# `build`

Builds a service with the given ID and attributes.

# `build!`

# `build!`

# `build_id`

# `check_setup`

```elixir
@spec check_setup(t()) :: :ok | {:error, term()}
```

Checks if the service's repository exists in its store.

# `default_graph`

Returns the default graph if one is designated.

This implementation of `c:DCATR.Service.Type.default_graph/1` delegates to
`DCATR.Service.Type.default_graph/1`.

# `from`

```elixir
@spec from(Grax.Schema.t()) :: {:ok, t()} | {:error, any()}
```

# `from!`

```elixir
@spec from!(Grax.Schema.t()) :: t()
```

# `graph`

```elixir
@spec graph(DCATR.GraphResolver.container(), DCATR.GraphResolver.id_or_selector()) ::
  DCATR.Graph.t() | nil
```

Returns a graph by ID, local name, or symbolic selector.

This overrides `DCATR.GraphResolver`'s generated `graph/2` to add local name lookup.

Delegates to `DCATR.Service.Type.graph/2`.

# `graph_by_id`

Returns a graph by its ID.

Delegates to `DCATR.Service.Type.graph_by_id/2`.

# `graph_by_name`

Returns a graph by its local name.

This implementation of `c:DCATR.Service.Type.graph_by_name/2` delegates to
`DCATR.Service.Type.graph_by_name/2`.

# `graph_name`

Returns the graph name for a given graph, selector, or ID.

This implementation of `c:DCATR.Service.Type.graph_name/3` delegates to
`DCATR.Service.Type.graph_name/3`.

# `graph_name_mapping`

Returns the complete local name to graph ID mapping.

Delegates to `DCATR.Service.Type.graph_name_mapping/1`.

# `graphs`

Returns all graphs aggregated from repository and local_data catalogs.

Delegates to `DCATR.Service.Type.graphs/1`.

# `handle_sparql`

Executes a `Gno.Store.SPARQL.Operation` through this service's store.

Resolves graph names via `graph_name/2` before dispatching to `Gno.Store`.

# `has_graph?`

```elixir
@spec has_graph?(
  DCATR.GraphResolver.container(),
  DCATR.GraphResolver.id_or_selector()
) :: boolean()
```

Checks if a graph exists in the container.

Convenience function based on `graph/2` - returns `true` if the graph exists,
`false` otherwise.

# `load`

```elixir
@spec load(
  RDF.Graph.t() | RDF.Description.t(),
  RDF.IRI.coercible() | RDF.BlankNode.t(),
  opts :: keyword()
) :: {:ok, t()} | {:error, any()}
```

# `load!`

```elixir
@spec load!(
  RDF.Graph.t() | RDF.Description.t(),
  RDF.IRI.coercible() | RDF.BlankNode.t(),
  opts :: keyword()
) :: t()
```

# `load_from_dataset`

Loads a service from a dataset.

This implementation of `c:DCATR.Service.Type.load_from_dataset/3` delegates to
`DCATR.Service.Type.load_from_dataset/4`.

# `load_graph_names`

Loads graph name mappings from a service manifest graph.

This implementation of `c:DCATR.Service.Type.load_graph_names/2` delegates to
`DCATR.Service.Type.load_graph_names/2`.

# `new`

Creates a new service with an auto-generated blank node ID.

# `new!`

# `primary_graph`

Returns the primary graph from the repository if one is designated.

This implementation of `c:DCATR.Service.Type.primary_graph/1` delegates to
`DCATR.Service.Type.primary_graph/1`.

# `repository_type`

Returns the repository type module for this service type.

# `resolve_graph_selector`

Resolves a symbolic selector to a graph.

This implementation of `c:DCATR.GraphResolver.resolve_graph_selector/2` delegates to
`DCATR.Service.Type.resolve_graph_selector/2`.

# `service_data_type`

Returns the service data type module for this service type.

# `use_primary_as_default`

Returns the effective value of `use_primary_as_default` for this service.

This implementation of `c:DCATR.Service.Type.use_primary_as_default/1` delegates to
`DCATR.Service.Type.use_primary_as_default/1`.

# `validate_setup`

```elixir
@spec validate_setup(t()) :: :ok | {:error, term()}
```

Validates basic setup integrity.

The default implementation checks for repository existence (same as `check_setup/1`).
Extensions can override this via `c:Gno.Service.Setup.Extension.validate/2` for
deeper structural validation.

---

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