# `Arangox.API.Graphs`
[🔗](https://github.com/ArangoDB-Community/arangox/blob/v0.8.0/lib/arangox/api/graphs.ex#L1)

ArangoDB's Graphs operations.

Every function takes the pool as its first argument and returns the decoded
response body. See `Arangox.API.Client` for the options they all accept and
for what a `404` returns.

# `add_vertex_collection`

```elixir
@spec add_vertex_collection(Arangox.conn(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Add a node collection

Adds a node collection to the set of orphan collections of the graph.
If the collection does not exist, it is created.

# `add_vertex_collection!`

```elixir
@spec add_vertex_collection!(Arangox.conn(), binary(), term(), keyword()) :: term()
```

Add a node collection. Raises on error.

See `add_vertex_collection/3`.

# `all`

```elixir
@spec all(
  Arangox.conn(),
  keyword()
) :: {:ok, term()} | {:error, Exception.t()}
```

List all graphs

Lists all graphs stored in this database.

## Returns

Recorded against ArangoDB 3.12.10:

    %{
      "code" => integer,
      "error" => boolean,
      "graphs" => [%{
        "_id" => string,
        "_key" => string,
        "_rev" => string,
        "edgeDefinitions" => [%{
          "collection" => string,
          "from" => [string],
          "to" => [string]
        }],
        "name" => string,
        "orphanCollections" => []
      }]
    }

# `all!`

```elixir
@spec all!(
  Arangox.conn(),
  keyword()
) :: term()
```

List all graphs. Raises on error.

See `all/1`.

# `all_edge_collections`

```elixir
@spec all_edge_collections(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

List edge collections

Lists all edge collections within this graph.

## Returns

Recorded against ArangoDB 3.12.10:

    %{
      "code" => integer,
      "collections" => [string],
      "error" => boolean
    }

# `all_edge_collections!`

```elixir
@spec all_edge_collections!(Arangox.conn(), binary(), keyword()) :: term()
```

List edge collections. Raises on error.

See `all_edge_collections/2`.

# `all_vertex_collections`

```elixir
@spec all_vertex_collections(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

List node collections

Lists all node collections within this graph, including orphan collections.

## Returns

Recorded against ArangoDB 3.12.10:

    %{
      "code" => integer,
      "collections" => [string],
      "error" => boolean
    }

# `all_vertex_collections!`

```elixir
@spec all_vertex_collections!(Arangox.conn(), binary(), keyword()) :: term()
```

List node collections. Raises on error.

See `all_vertex_collections/2`.

# `create`

```elixir
@spec create(Arangox.conn(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Create a graph

The creation of a graph requires the name of the graph and a
definition of its edges.

# `create!`

```elixir
@spec create!(Arangox.conn(), term(), keyword()) :: term()
```

Create a graph. Raises on error.

See `create/2`.

# `create_edge`

```elixir
@spec create_edge(Arangox.conn(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Create an edge

Creates a new edge in the specified collection.
Within the body the edge has to contain a `_from` and `_to` value referencing to valid nodes in the graph.
Furthermore, the edge has to be valid according to the edge definitions.

# `create_edge!`

```elixir
@spec create_edge!(Arangox.conn(), binary(), binary(), term(), keyword()) :: term()
```

Create an edge. Raises on error.

See `create_edge/4`.

# `create_edge_definition`

```elixir
@spec create_edge_definition(Arangox.conn(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Add an edge definition

Adds an additional edge definition to the graph.

This edge definition has to contain a `collection` and an array of
each `from` and `to` node collections. An edge definition can only
be added if this definition is either not used in any other graph, or
it is used with exactly the same definition. For example, it is not
possible to store a definition "e" from "v1" to "v2" in one graph, and
"e" from "v2" to "v1" in another graph, but both can have "e" from
"v1" to "v2".

Additionally, collection creation options can be set.

# `create_edge_definition!`

```elixir
@spec create_edge_definition!(Arangox.conn(), binary(), term(), keyword()) :: term()
```

Add an edge definition. Raises on error.

See `create_edge_definition/3`.

# `create_vertex`

```elixir
@spec create_vertex(Arangox.conn(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Create a node

Adds a node to the given collection.

# `create_vertex!`

```elixir
@spec create_vertex!(Arangox.conn(), binary(), binary(), term(), keyword()) :: term()
```

Create a node. Raises on error.

See `create_vertex/4`.

# `delete`

```elixir
@spec delete(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Drop a graph

Drops an existing graph object by name.
Optionally all collections not used by other graphs
can be dropped as well.

# `delete!`

```elixir
@spec delete!(Arangox.conn(), binary(), keyword()) :: term()
```

Drop a graph. Raises on error.

See `delete/2`.

# `delete_edge`

```elixir
@spec delete_edge(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Remove an edge

Removes an edge from an edge collection of the named graph. Any other edges
that directly reference this edge like a node are removed, too.

# `delete_edge!`

```elixir
@spec delete_edge!(Arangox.conn(), binary(), binary(), binary(), keyword()) :: term()
```

Remove an edge. Raises on error.

See `delete_edge/4`.

# `delete_edge_definition`

```elixir
@spec delete_edge_definition(Arangox.conn(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Remove an edge definition

Remove one edge definition from the graph. This only removes the
edge collection from the graph definition. The node collections of the
edge definition become orphan collections but otherwise remain untouched
and can still be used in your queries.

# `delete_edge_definition!`

```elixir
@spec delete_edge_definition!(Arangox.conn(), binary(), binary(), keyword()) :: term()
```

Remove an edge definition. Raises on error.

See `delete_edge_definition/3`.

# `delete_vertex`

```elixir
@spec delete_vertex(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Remove a node

Removes a node from a collection of the named graph. Additionally removes all
incoming and outgoing edges of the node.

# `delete_vertex!`

```elixir
@spec delete_vertex!(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  term()
```

Remove a node. Raises on error.

See `delete_vertex/4`.

# `delete_vertex_collection`

```elixir
@spec delete_vertex_collection(Arangox.conn(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Remove a node collection

Removes a node collection from the list of the graph's
orphan collections. It can optionally delete the collection if it is
not used in any other graph.

You cannot remove node collections that are used in one of the
edge definitions of the graph. You need to modify or remove the
edge definition first in order to fully remove a node collection from
the graph.

# `delete_vertex_collection!`

```elixir
@spec delete_vertex_collection!(Arangox.conn(), binary(), binary(), keyword()) ::
  term()
```

Remove a node collection. Raises on error.

See `delete_vertex_collection/3`.

# `get`

```elixir
@spec get(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Get a graph

Selects information for a given graph.
Returns the edge definitions as well as the orphan collections,
or returns an error if the graph does not exist.

## Returns

Recorded against ArangoDB 3.12.10:

    %{
      "code" => integer,
      "error" => boolean,
      "graph" => %{
        "_id" => string,
        "_key" => string,
        "_rev" => string,
        "edgeDefinitions" => [%{
          "collection" => string,
          "from" => [string],
          "to" => [string]
        }],
        "name" => string,
        "orphanCollections" => []
      }
    }

# `get!`

```elixir
@spec get!(Arangox.conn(), binary(), keyword()) :: term()
```

Get a graph. Raises on error.

See `get/2`.

# `get_edge`

```elixir
@spec get_edge(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Get an edge

Gets an edge from the given collection.

# `get_edge!`

```elixir
@spec get_edge!(Arangox.conn(), binary(), binary(), binary(), keyword()) :: term()
```

Get an edge. Raises on error.

See `get_edge/4`.

# `get_vertex`

```elixir
@spec get_vertex(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Get a node

Gets a node from the given collection.

## Returns

Recorded against ArangoDB 3.12.10:

    %{
      "code" => integer,
      "error" => boolean,
      "vertex" => %{
        "_id" => string,
        "_key" => string,
        "_rev" => string
      }
    }

# `get_vertex!`

```elixir
@spec get_vertex!(Arangox.conn(), binary(), binary(), binary(), keyword()) :: term()
```

Get a node. Raises on error.

See `get_vertex/4`.

# `replace_edge`

```elixir
@spec replace_edge(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Replace an edge

Replaces the data of an edge in the collection.

# `replace_edge!`

```elixir
@spec replace_edge!(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  term()
```

Replace an edge. Raises on error.

See `replace_edge/5`.

# `replace_edge_definition`

```elixir
@spec replace_edge_definition(Arangox.conn(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Replace an edge definition

Change the node collections of one specific edge definition.
This modifies all occurrences of this definition in all graphs known to your database.

# `replace_edge_definition!`

```elixir
@spec replace_edge_definition!(Arangox.conn(), binary(), binary(), term(), keyword()) ::
  term()
```

Replace an edge definition. Raises on error.

See `replace_edge_definition/4`.

# `replace_vertex`

```elixir
@spec replace_vertex(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Replace a node

Replaces the data of a node in the collection.

# `replace_vertex!`

```elixir
@spec replace_vertex!(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  term()
```

Replace a node. Raises on error.

See `replace_vertex/5`.

# `update_edge`

```elixir
@spec update_edge(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Update an edge

Partially modify the data of the specific edge in the collection.

# `update_edge!`

```elixir
@spec update_edge!(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  term()
```

Update an edge. Raises on error.

See `update_edge/5`.

# `update_vertex`

```elixir
@spec update_vertex(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Update a node

Updates the data of the specific node in the collection.

# `update_vertex!`

```elixir
@spec update_vertex!(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  term()
```

Update a node. Raises on error.

See `update_vertex/5`.

# `vertex_edges`

```elixir
@spec vertex_edges(Arangox.conn(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Get inbound and outbound edges

Returns an array of edges starting or ending in the node identified by
`vertex`.

## Returns

Recorded against ArangoDB 3.12.10:

    %{
      "code" => integer,
      "edges" => [%{
        "_from" => string,
        "_id" => string,
        "_key" => string,
        "_rev" => string,
        "_to" => string
      }],
      "error" => boolean,
      "stats" => %{
        "cacheHits" => integer,
        "cacheMisses" => integer,
        "cursorsCreated" => integer,
        "cursorsRearmed" => integer,
        "documentLookups" => integer,
        "executionTime" => float,
        "filtered" => integer,
        "httpRequests" => integer,
        "intermediateCommits" => integer,
        "peakMemoryUsage" => integer,
        "scannedFull" => integer,
        "scannedIndex" => integer,
        "searchParallelism" => integer,
        "seeks" => integer,
        "writesExecuted" => integer,
        "writesIgnored" => integer
      }
    }

# `vertex_edges!`

```elixir
@spec vertex_edges!(Arangox.conn(), binary(), binary(), keyword()) :: term()
```

Get inbound and outbound edges. Raises on error.

See `vertex_edges/3`.

---

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