Skip to content

Commit 95ec337

Browse files
authored
Merge pull request #282 from luffy1727/adding-transaction-timeout
Add an example of how to configure transaction properties
2 parents 4eb03fa + 88e18a6 commit 95ec337

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

modules/ROOT/pages/driver-configuration.adoc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,44 @@ await startStandaloneServer(server, {
143143
144144
----
145145

146+
==== Transaction configuration in context
147+
148+
[source, javascript, indent=0]
149+
----
150+
import { ApolloServer } from "@apollo/server";
151+
import { startStandaloneServer } from "@apollo/server/standalone";
152+
import { Neo4jGraphQL } from "@neo4j/graphql";
153+
import neo4j from "neo4j-driver";
154+
155+
const typeDefs = `#graphql
156+
type User @node {
157+
name: String
158+
}
159+
`;
160+
161+
const driver = neo4j.driver(
162+
"bolt://localhost:7687",
163+
neo4j.auth.basic("username", "password")
164+
);
165+
const session = driver.session();
166+
const transactionConfig = {
167+
timeout: 60 * 1000,
168+
metadata: {
169+
"my-very-own-metadata": "is very good!"
170+
}
171+
};
172+
173+
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
174+
175+
const server = new ApolloServer({
176+
schema: await neoSchema.getSchema(),
177+
});
178+
179+
await startStandaloneServer(server, {
180+
context: async ({ req }) => ({ req, transaction: transactionConfig }),
181+
});
182+
----
183+
146184
[[driver-configuration-database-compatibility]]
147185
== Database compatibility
148186

0 commit comments

Comments
 (0)