-
Notifications
You must be signed in to change notification settings - Fork 2
/
plugin.ts
31 lines (30 loc) · 945 Bytes
/
plugin.ts
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
import { ApolloServerPlugin } from "apollo-server-plugin-base";
//plugin GraphQL request lifecycle
import { Context } from "./context";
const plugin: ApolloServerPlugin<Context> = {
//community inspiration: https://gist.github.com/efueyo/eec3aa5115ea63005e92337f3205ccdb#file-sentry-plugin-ts
requestDidStart({ request, context }) {
if (!!request.operationName) {
context.transaction.setName(request.operationName!);
}
return {
willSendResponse({ context }) {
context.transaction.finish();
},
executionDidStart() {
return {
willResolveField({ context, info }) {
const span = context.transaction.startChild({
op: "resolver",
description: `${info.parentType.name}.${info.fieldName}`,
});
return () => {
span.finish();
};
},
};
},
};
},
};
export default plugin;