diff --git a/plugins/node/opentelemetry-instrumentation-graphql/.tav.yml b/plugins/node/opentelemetry-instrumentation-graphql/.tav.yml index 52b6d2bcd3..603ce40daf 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/.tav.yml +++ b/plugins/node/opentelemetry-instrumentation-graphql/.tav.yml @@ -1,4 +1,4 @@ graphql: # Taking a sample from the most downloaded versions in the range "14 || 15 || 16" - versions: "^16.4.0 || 16.3.0 || 16.2.0 || ^15.8.0 || 15.7.2 || 15.6.1 || 15.6.0 || 15.5.3 || 15.5.1 || 15.5.0 || 15.4.0 || 15.3.0 || 14.7.0 || 14.6.0 || 14.5.8 || 14.0.0" + versions: "16.4.0 || 16.3.0 || 16.2.0 || 16.0.0 || ^15.8.0 || 15.7.2 || 15.6.1 || 15.6.0 || 15.5.3 || 15.5.1 || 15.5.0 || 15.4.0 || 15.3.0 || ^14.7.0 || 14.6.0 || 14.5.8 || 14.0.0" commands: npm run test diff --git a/plugins/node/opentelemetry-instrumentation-graphql/package.json b/plugins/node/opentelemetry-instrumentation-graphql/package.json index b0f75720fe..5263b7c7e3 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/package.json +++ b/plugins/node/opentelemetry-instrumentation-graphql/package.json @@ -52,7 +52,7 @@ "@opentelemetry/sdk-trace-base": "1.2.0", "@types/mocha": "8.2.3", "@types/node": "16.11.21", - "graphql": "^15.5.1", + "graphql": "^16.5.0", "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts index 52c7465a2f..efb54b6c87 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts @@ -307,8 +307,8 @@ export class GraphQLInstrumentation extends InstrumentationBase { schema: graphqlTypes.GraphQLSchema, documentAST: graphqlTypes.DocumentNode, rules?: ReadonlyArray, - typeInfo?: graphqlTypes.TypeInfo, - options?: { maxErrors?: number } + options?: { maxErrors?: number }, + typeInfo?: graphqlTypes.TypeInfo ): ReadonlyArray { return instrumentation._validate( this, @@ -373,8 +373,8 @@ export class GraphQLInstrumentation extends InstrumentationBase { schema, documentAST, rules, - typeInfo, - options + options, + typeInfo ); }, (err, errors) => { diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts index 7f457dafcf..f783140bed 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts @@ -120,8 +120,8 @@ export type validateType = ( schema: graphqlTypes.GraphQLSchema, documentAST: graphqlTypes.DocumentNode, rules?: ReadonlyArray, - typeInfo?: graphqlTypes.TypeInfo, - options?: { maxErrors?: number } + options?: { maxErrors?: number }, + typeInfo?: graphqlTypes.TypeInfo ) => ReadonlyArray; export interface GraphQLField { diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts index 052953a5e5..0a938dfb72 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts @@ -387,7 +387,13 @@ export function wrapFieldResolver( > >( () => { - return fieldResolver.call(this, source, args, contextValue, info); + return fieldResolver.call( + this, + source, + args, + contextValue, + info + ) as any; }, err => { if (shouldEndSpan) { @@ -421,7 +427,7 @@ async function safeExecuteInTheMiddleAsync( try { result = await execute(); } catch (e) { - error = e; + error = e as Error; } finally { onFinish(error, result); if (error && !preventThrowingError) { diff --git a/plugins/node/opentelemetry-instrumentation-graphql/test/graphql.test.ts b/plugins/node/opentelemetry-instrumentation-graphql/test/graphql.test.ts index 058e15d0c5..390893bf46 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/test/graphql.test.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/test/graphql.test.ts @@ -96,6 +96,9 @@ const provider = new BasicTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); graphQLInstrumentation.setTracerProvider(provider); +const majorNodeVersion = Number(process.version.substring(1).split('.')[0]); +const itMaybe = majorNodeVersion >= 12 ? it : it.skip; + describe('graphql', () => { function create(config: GraphQLInstrumentationConfig = {}) { graphQLInstrumentation.setConfig(config); @@ -976,7 +979,7 @@ describe('graphql', () => { assert.deepStrictEqual(spans.length, 1); }); - it('should instrument parse with error', () => { + itMaybe('should instrument parse with error', () => { const parseSpan = spans[0]; const event = parseSpan.events[0]; @@ -1043,7 +1046,7 @@ describe('graphql', () => { describe('responseHook', () => { let spans: ReadableSpan[]; - let graphqlResult: graphqlTypes.ExecutionResult; + let graphqlResult: graphqlTypes.ExecutionResult<{ books: unknown[] }>; const dataAttributeName = 'graphql_data'; afterEach(() => {