-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathscenario-mutation.js
More file actions
45 lines (38 loc) · 1.24 KB
/
scenario-mutation.js
File metadata and controls
45 lines (38 loc) · 1.24 KB
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
37
38
39
40
41
42
43
44
45
const Sentry = require('@sentry/node');
const { loggingTransport } = require('@sentry-internal/node-integration-tests');
const client = Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
tracesSampleRate: 1.0,
integrations: [Sentry.graphqlIntegration({ useOperationNameForRootSpan: true })],
transport: loggingTransport,
});
const tracer = client.tracer;
// Stop the process from exiting before the transaction is sent
setInterval(() => {}, 1000);
async function run() {
const { gql } = require('apollo-server');
const server = require('../apollo-server')();
await tracer.startActiveSpan(
'test span name',
{
kind: 1,
attributes: { 'http.method': 'GET', 'http.route': '/test-graphql' },
},
async span => {
// Ref: https://www.apollographql.com/docs/apollo-server/testing/testing/#testing-using-executeoperation
await server.executeOperation({
query: gql`mutation TestMutation($email: String){
login(email: $email)
}`,
variables: { email: 'test@email.com' },
});
setTimeout(() => {
span.end();
server.stop();
}, 500);
},
);
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
run();