Skip to content

Commit 5405f83

Browse files
Feature/graph endpoint support (#1)
Graph schema documentation
1 parent 5fb4ae4 commit 5405f83

11 files changed

+714
-14
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ $client->transactions()->begin(['write' => ['users', 'teams']]);
9090
3) [Collection schema](docs/schema-collections.md)
9191
4) [Index schema](docs/schema-indexes.md)
9292
5) [View schema](docs/schema-views.md)
93+
6) [Graph schema](docs/schema-graphs.md)
9394
5) [Transaction manager](docs/transaction-manager.md)
9495

9596
## Related packages

docs/schema-graphs.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Schema manager - Graphs
2+
You can use the schema manager to perform CRUD actions on named graphs.
3+
4+
## Graph functions
5+
The schema manager supports the following graph functions:
6+
7+
### public function createGraph(string $name, array $config = [], $waitForSync = false)
8+
```
9+
$arangoClient->schema()->createGraph(
10+
'relations',
11+
[
12+
'edgeDefinitions' => [
13+
[
14+
'collection' => 'children',
15+
'from' => ['characters'],
16+
'to' => ['characters']
17+
]
18+
],
19+
'orphanCollections' => [
20+
'orphanVertices'
21+
],
22+
],
23+
true
24+
);
25+
```
26+
27+
### getGraph(string $name): array
28+
```
29+
$arangoClient->schema()->getGraphs('relations');
30+
```
31+
32+
### getGraphs(): array
33+
```
34+
$arangoClient->schema()->getGraphs();
35+
```
36+
37+
### hasGraph(string $name): bool
38+
```
39+
$arangoClient->schema()->hasGraph('relations');
40+
```
41+
42+
### deleteGraph(string $name): bool
43+
```
44+
$arangoClient->schema()->deleteGraph('locations');
45+
```
46+
47+
### getGraphVertices(string $name): array
48+
```
49+
$arangoClient->schema()->getGraphVertices('relations');
50+
```
51+
52+
### addGraphVertex(string $name, string $vertex): array
53+
```
54+
$arangoClient->schema()->addGraphVertex('relations', 'houses');
55+
```
56+
57+
### removeGraphVertex(string $name, string $vertex, bool $dropCollection = false): array
58+
```
59+
$arangoClient->schema()->removeGraphVertex('relations', 'houses', true);
60+
```
61+
62+
### getGraphEdges(string $name): array
63+
```
64+
$arangoClient->schema()->deleteGraph('locations');
65+
```
66+
67+
### addGraphEdge(string $name, array $edgeDefinition): array
68+
```
69+
$arangoClient->schema()->addGraphEdge(
70+
'relations',
71+
[
72+
'collection' => 'vassals',
73+
'from' => ['characters'],
74+
'to' => ['houses']
75+
]
76+
);
77+
```
78+
79+
### replaceGraphEdge(string $name, string $edge, array $edgeDefinition, bool $dropCollection = false, bool $waitForSync = false): array
80+
```
81+
$arangoClient->schema()->createGraph(
82+
'relations',
83+
[
84+
'edgeDefinitions' => [
85+
[
86+
'collection' => 'children',
87+
'from' => ['characters'],
88+
'to' => ['characters']
89+
]
90+
]
91+
]
92+
);
93+
```
94+
95+
### removeGraphEdge(string $name, string $edge, bool $dropCollection = true, bool $waitForSync = false): array
96+
```
97+
$arangoClient->schema()->removeGraphEdge(
98+
'relations',
99+
'children',
100+
true,
101+
true
102+
);
103+
```
104+

docs/schema-views.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Schema manager - Views
2-
You can use the schema manager to perform CRUD actions on indexes within a collection.
2+
You can use the schema manager to perform CRUD actions on ArangoSearch views.
33

44
## View functions
55
The schema manager supports the following index functions:

src/ArangoClient.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ public function __construct(array $config = [], GuzzleClient $httpClient = null)
4343
$config['endpoint'] = $this->generateEndpoint($config);
4444
$this->config = new HttpClientConfig($config);
4545

46-
$this->httpClient = isset($httpClient)
47-
? $httpClient
48-
: new GuzzleClient($this->config->mapGuzzleHttpClientConfig());
46+
$this->httpClient = $httpClient ?? new GuzzleClient($this->config->mapGuzzleHttpClientConfig());
4947
}
5048

5149
/**
@@ -156,10 +154,10 @@ protected function handleGuzzleException(Throwable $e): void
156154
}
157155

158156
throw(
159-
new ArangoException(
160-
$message,
161-
(int) $code
162-
)
157+
new ArangoException(
158+
$code . ' - ' . $message,
159+
(int) $code
160+
)
163161
);
164162
}
165163

src/Exceptions/ArangoException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44

55
class ArangoException extends \Exception
66
{
7-
87
}

src/Schema/ManagesCollections.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use ArangoClient\ArangoClient;
88
use ArangoClient\Exceptions\ArangoException;
99

10-
/*
10+
/**
1111
* @see https://www.arangodb.com/docs/stable/http/collection.html
1212
*/
1313
trait ManagesCollections

0 commit comments

Comments
 (0)