forked from fastify/benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathapollo-opentracing.js
36 lines (33 loc) · 948 Bytes
/
apollo-opentracing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"use strict";
const cors = require("cors");
const { ApolloServer } = require("@apollo/server");
const { expressMiddleware } = require("@apollo/server/express4");
const OpentracingPlugin = require("apollo-opentracing").default;
const express = require("express");
const { createApolloSchema } = require("../lib/schemas/createApolloSchema");
if (true) {
throw new Error(
"https://github.com/DanielMSchmidt/apollo-opentracing/issues/573",
);
}
const app = express();
const schema = createApolloSchema();
const server = new ApolloServer({
schema,
plugins: [
OpentracingPlugin({
server: {
startSpan: () => ({ finish: () => ({}) }),
extract: () => ({}),
finish: () => ({}),
},
local: {
startSpan: () => ({ finish: () => ({}) }),
},
}),
],
});
server.start().then(() => {
app.use("/graphql", cors(), express.json(), expressMiddleware(server, {}));
app.listen(4001);
});