@@ -2,37 +2,61 @@ import { conditionalTest } from '../../../utils';
22import { createRunner } from '../../../utils/runner' ;
33
44conditionalTest ( { min : 14 } ) ( 'GraphQL/Apollo Tests' , ( ) => {
5- const EXPECTED_TRANSACTION = {
6- transaction : 'Test Transaction' ,
7- spans : expect . arrayContaining ( [
8- expect . objectContaining ( {
9- data : {
10- 'graphql.operation.type' : 'query' ,
11- 'graphql.source' : '{hello}' ,
12- 'otel.kind' : 'INTERNAL' ,
13- 'sentry.origin' : 'auto.graphql.otel.graphql' ,
14- } ,
15- description : 'query' ,
16- status : 'ok' ,
17- origin : 'auto.graphql.otel.graphql' ,
18- } ) ,
19- expect . objectContaining ( {
20- data : {
21- 'graphql.field.name' : 'hello' ,
22- 'graphql.field.path' : 'hello' ,
23- 'graphql.field.type' : 'String' ,
24- 'graphql.source' : 'hello' ,
25- 'otel.kind' : 'INTERNAL' ,
26- 'sentry.origin' : 'manual' ,
27- } ,
28- description : 'graphql.resolve' ,
29- status : 'ok' ,
30- origin : 'manual' ,
31- } ) ,
32- ] ) ,
33- } ;
34-
355 test ( 'CJS - should instrument GraphQL queries used from Apollo Server.' , done => {
36- createRunner ( __dirname , 'scenario.js' ) . expect ( { transaction : EXPECTED_TRANSACTION } ) . start ( done ) ;
6+ const EXPECTED_TRANSACTION = {
7+ transaction : 'Test Transaction' ,
8+ spans : expect . arrayContaining ( [
9+ expect . objectContaining ( {
10+ data : {
11+ 'graphql.operation.type' : 'query' ,
12+ 'graphql.source' : '{hello}' ,
13+ 'otel.kind' : 'INTERNAL' ,
14+ 'sentry.origin' : 'auto.graphql.otel.graphql' ,
15+ } ,
16+ description : 'query' ,
17+ status : 'ok' ,
18+ origin : 'auto.graphql.otel.graphql' ,
19+ } ) ,
20+ expect . objectContaining ( {
21+ data : {
22+ 'graphql.field.name' : 'hello' ,
23+ 'graphql.field.path' : 'hello' ,
24+ 'graphql.field.type' : 'String' ,
25+ 'graphql.source' : 'hello' ,
26+ 'otel.kind' : 'INTERNAL' ,
27+ 'sentry.origin' : 'manual' ,
28+ } ,
29+ description : 'graphql.resolve' ,
30+ status : 'ok' ,
31+ origin : 'manual' ,
32+ } ) ,
33+ ] ) ,
34+ } ;
35+
36+ createRunner ( __dirname , 'scenario-query.js' ) . expect ( { transaction : EXPECTED_TRANSACTION } ) . start ( done ) ;
37+ } ) ;
38+
39+ test ( 'CJS - should instrument GraphQL mutations used from Apollo Server.' , done => {
40+ const EXPECTED_TRANSACTION = {
41+ transaction : 'Test Transaction' ,
42+ spans : expect . arrayContaining ( [
43+ expect . objectContaining ( {
44+ data : {
45+ 'graphql.operation.name' : 'Mutation' ,
46+ 'graphql.operation.type' : 'mutation' ,
47+ 'graphql.source' : `mutation Mutation($email: String) {
48+ login(email: $email)
49+ }` ,
50+ 'otel.kind' : 'INTERNAL' ,
51+ 'sentry.origin' : 'auto.graphql.otel.graphql' ,
52+ } ,
53+ description : 'mutation Mutation' ,
54+ status : 'ok' ,
55+ origin : 'auto.graphql.otel.graphql' ,
56+ } ) ,
57+ ] ) ,
58+ } ;
59+
60+ createRunner ( __dirname , 'scenario-mutation.js' ) . expect ( { transaction : EXPECTED_TRANSACTION } ) . start ( done ) ;
3761 } ) ;
3862} ) ;
0 commit comments