Skip to content

Commit 392779c

Browse files
authored
Merge pull request #1 from ltwlf/dev
arangorizeSchema
2 parents 29784b1 + dc99043 commit 392779c

File tree

7 files changed

+14719
-6907
lines changed

7 files changed

+14719
-6907
lines changed

.github/workflows/nodejs.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@ on: [push]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
98

109
strategy:
1110
matrix:
12-
node-version: [8.x, 10.x, 12.x]
11+
node-version: [10.x, 12.x]
1312

1413
steps:
15-
- uses: actions/checkout@v1
16-
- name: Use Node.js ${{ matrix.node-version }}
17-
uses: actions/setup-node@v1
18-
with:
19-
node-version: ${{ matrix.node-version }}
20-
- name: npm install, build, and test
21-
run: |
22-
npm ci
23-
npm run build --if-present
24-
npm test
25-
env:
26-
CI: true
14+
- uses: actions/checkout@v1
15+
- name: Use Node.js ${{ matrix.node-version }}
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
- name: npm install, build, and test
20+
run: |
21+
npm ci
22+
npm run build --if-present
23+
npm test
24+
env:
25+
CI: true

README.md

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,6 @@ You may also need to install peer dependencies if you don't have them:
9999
npm i --save graphql arangojs
100100
```
101101

102-
### Directive type definitions
103-
104-
To use the directives in this library, you need to add type definitions for them. The library exports pre-built type definitions for all directives, you just need to include them in your type definitions.
105-
106-
```ts
107-
import { directiveTypeDefs } from 'graphql-arangodb';
108-
109-
const typeDefs = [directiveTypeDefs, ...allYourAppsOtherTypeDefs];
110-
111-
makeExecutableSchema({ typeDefs });
112-
```
113-
114102
### Adding a Database instance
115103

116104
The easiest way to connect `graphql-arangodb` to your ArangoDB database is to instantiate a `Database` class from `arangojs` and assign it to the `arangoDb` field of your GraphQL `context`:
@@ -129,6 +117,61 @@ const context = {
129117
// pass the context into your GraphQL server according to documentation of the server
130118
```
131119

120+
### Directive type definitions
121+
122+
To use the directives in this library, you need to add type definitions for them. The library exports pre-built type definitions for all directives, you can either include them manually,
123+
124+
```ts
125+
import { directiveTypeDefs } from 'graphql-arangodb';
126+
127+
const typeDefs = [directiveTypeDefs, ...allYourAppsOtherTypeDefs];
128+
129+
makeExecutableSchema({ typeDefs });
130+
```
131+
132+
or you can use the arangorizeSchema generator. arangorizeSchema can additionaly automatically create document and edge collections and indexes:
133+
134+
Schema example:
135+
136+
```graphql
137+
type User @aqlCollection(name: "users" ) {
138+
id: String! @aqlIndex(type: UNIQUE)
139+
name: String!
140+
friends: [FriendOfEdge!]!
141+
@aqlEdge(
142+
collection: "friendOf"
143+
direction: ANY
144+
sort: { property: "name", sortOn: "$field_node" }
145+
)
146+
}
147+
148+
@aqlCollection(name: "friendOf", type: EDGE )
149+
type FriendOfEdge {
150+
strength: Int
151+
user: User! @aqlEdgeNode
152+
}
153+
```
154+
155+
```TS
156+
import { arangorizeSchema } from 'graphql-arangodb';
157+
158+
const typeDefs = [...allYourAppsOtherTypeDefs];
159+
const resolvers = { ...allYourResolvers}
160+
161+
await arangorizeSchema({ typeDefs, resolvers }, db );
162+
```
163+
164+
As an optional, last parameter you can add a database name when you want to ensure a database exisits. If the database does not exists it will be created.
165+
166+
```TS
167+
import { arangorizeSchema } from 'graphql-arangodb';
168+
169+
const typeDefs = [...allYourAppsOtherTypeDefs];
170+
const resolvers = { ...allYourResolvers}
171+
172+
await arangorizeSchema({ typeDefs, resolvers }, db, 'myAwesomeDB');
173+
```
174+
132175
### Resolvers
133176

134177
To start resolving queries using AQL, you need to set up resolvers for fields which will be resolved using those queries. For most use cases, this means all of the top-level fields in the root query and mutation types.

0 commit comments

Comments
 (0)