You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+55-12Lines changed: 55 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -99,18 +99,6 @@ You may also need to install peer dependencies if you don't have them:
99
99
npm i --save graphql arangojs
100
100
```
101
101
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';
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`:
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,
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
+
typeUser@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
+
typeFriendOfEdge {
150
+
strength: Int
151
+
user: User!@aqlEdgeNode
152
+
}
153
+
```
154
+
155
+
```TS
156
+
import { arangorizeSchema } from 'graphql-arangodb';
157
+
158
+
consttypeDefs = [...allYourAppsOtherTypeDefs];
159
+
constresolvers = { ...allYourResolvers}
160
+
161
+
awaitarangorizeSchema({ 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.
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