@@ -5,13 +5,13 @@ import { Integrations, Transaction } from "@sentry/tracing";
5
5
import { BaseRedisCache } from "apollo-server-cache-redis" ;
6
6
import { InMemoryLRUCache } from "apollo-server-caching" ;
7
7
import {
8
- ApolloServerPluginCacheControl ,
9
- ApolloServerPluginDrainHttpServer ,
10
- ApolloServerPluginLandingPageDisabled ,
8
+ ApolloServerPluginCacheControl ,
9
+ ApolloServerPluginDrainHttpServer ,
10
+ ApolloServerPluginLandingPageDisabled
11
11
} from "apollo-server-core" ;
12
12
import { ApolloServer } from "apollo-server-fastify" ;
13
13
import responseCachePlugin from "apollo-server-plugin-response-cache" ;
14
- import fastify , { FastifyContext } from "fastify" ;
14
+ import fastify , { FastifyContext , FastifyReply , FastifyRequest } from "fastify" ;
15
15
import Redis from "ioredis" ;
16
16
import { MongoClient } from "mongodb" ;
17
17
import pEvent from "p-event" ;
@@ -63,12 +63,17 @@ export interface Context {
63
63
async function run ( ) {
64
64
const apolloGenericSettings = {
65
65
dataSources : ( ) => dSources ,
66
- context : ( ) => ( {
67
- transaction : Sentry . startTransaction ( {
68
- op : "gql" ,
69
- name : "GraphQLTransaction"
70
- } )
71
- } ) ,
66
+ context : ( req : FastifyRequest , res : FastifyReply ) => {
67
+ Sentry . setUser ( {
68
+ ip_address : req . ip
69
+ } ) ;
70
+ return {
71
+ transaction : Sentry . startTransaction ( {
72
+ op : "gql" ,
73
+ name : "GraphQLTransaction"
74
+ } )
75
+ } ;
76
+ } ,
72
77
introspection : true ,
73
78
cache : baseRedisCache ,
74
79
plugins : [
0 commit comments