Skip to content

Commit d8bbf3a

Browse files
jmesimaktrentm
andcommitted
feat: add @apollo/server@4 support (#3203)
Closes: #2980 Co-authored-by: Trent Mick <[email protected]>
1 parent 6740013 commit d8bbf3a

File tree

9 files changed

+896
-15
lines changed

9 files changed

+896
-15
lines changed

.ci/tav.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"// todo": "We want versions=['20','19','18','16','14','12','10','8'], but versions*modules needs to be <256 for the GH Actions jobs limit",
33
"versions": [ "20", "18", "16", "14", "12", "10", "8" ],
44
"modules": [
5+
"@apollo/server",
56
"@aws-sdk/client-s3",
67
"@elastic/elasticsearch",
78
"@elastic/elasticsearch-canary",

.tav.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# This file is used by tool TAV - Test All Versions.
22
# See: https://github.com/watson/test-all-versions
33

4+
'@apollo/server':
5+
versions: ^4.0.0
6+
peerDependencies: graphql@^16.6.0
7+
node: '>=14.16.0'
8+
commands: node test/instrumentation/modules/@apollo/server.test.js
9+
410
generic-pool:
511
versions: ^2.0.0 || ^3.1.0
612
commands: node test/instrumentation/modules/generic-pool.test.js

docs/supported-technologies.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ These modules override that behavior to give better insights into specialized HT
127127
|Module |Version |Note
128128
|https://www.npmjs.com/package/express-graphql[express-graphql] |>=0.6.1 <0.13.0 |Will name all transactions by the GraphQL query name. There is a https://github.com/elastic/apm-agent-nodejs/issues/2516[known issue with node <10.4]. This module is deprecated and is no longer tested.
129129
|https://www.npmjs.com/package/apollo-server-express[apollo-server-express] |>=2.0.4 <4|Will name all transactions by the GraphQL query name. Versions before 2.9.6 are no longer tested.
130+
|https://www.npmjs.com/package/@apollo/server[@apollo/server] |>=4.0.0|Will name all transactions by the GraphQL query name
130131
|=======================================================================
131132

132133
[float]

lib/instrumentation/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const nodeSupportsAsyncLocalStorage = semver.satisfies(process.versions.node, '>
3131
const nodeHasInstrumentableFetch = typeof (global.fetch) === 'function'
3232

3333
var MODULES = [
34+
'@apollo/server',
3435
'@aws-sdk/smithy-client', // Instrument the base client which all AWS-SDK v3 clients extends
3536
['@elastic/elasticsearch', '@elastic/elasticsearch-canary'],
3637
'@node-redis/client/dist/lib/client',
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and other contributors where applicable.
3+
* Licensed under the BSD 2-Clause License; you may not use this file except in
4+
* compliance with the BSD 2-Clause License.
5+
*/
6+
7+
'use strict'
8+
9+
const shimmer = require('../../shimmer')
10+
11+
module.exports = function (apolloServer, agent, { enabled }) {
12+
if (!enabled) {
13+
return apolloServer
14+
}
15+
16+
function wrapExecuteHTTPGraphQLRequest (orig) {
17+
return function wrappedExecuteHTTPGraphQLRequest () {
18+
var trans = agent._instrumentation.currTransaction()
19+
if (trans) trans._graphqlRoute = true
20+
return orig.apply(this, arguments)
21+
}
22+
}
23+
24+
shimmer.wrap(apolloServer.ApolloServer.prototype, 'executeHTTPGraphQLRequest', wrapExecuteHTTPGraphQLRequest)
25+
return apolloServer
26+
}

0 commit comments

Comments
 (0)