opentelemetry-js-contrib: `@opentelemetry/instrumentation-graphql` Version `0.27.1` Missing `@types/graphql` dependency

What version of OpenTelemetry are you using?

1.0.4

What version of Node are you using?

v16.11.0

Please provide the code you used to setup the OpenTelemetry SDK

import { GraphQLInstrumentation } from "@opentelemetry/instrumentation-graphql";

What did you do?

In a fresh folder

yarn add @opentelemetry/api 
yarn add @opentelemetry/instrumentation-graphql
yarn add -D typescript

Add the build script to your package.json

{
  "scripts": {
    "build": "tsc otel.ts"
  },
  "devDependencies": {
    "typescript": "^4.5.4"
  },
  "dependencies": {
    "@opentelemetry/api": "^1.0.4",
    "@opentelemetry/instrumentation-graphql": "^0.27.1"
  }
}

Attempt to compile the typescript

yarn build

What did you expect to see?

I expected the file to compile successfully

What did you see instead?

The file failed to compile because the graphql dependency was not installed

$ tsc otel.ts
node_modules/@opentelemetry/instrumentation-graphql/build/src/instrumentation.d.ts:2:36 - error TS2307: Cannot find module 'graphql' or its corresponding type declarations.

2 import type * as graphqlTypes from 'graphql';

Additional context

In Version 0.26.1 it contains the dependency "@types/graphql": "14.5.0" which has somehow been dropped in the latest version

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 19 (14 by maintainers)

Most upvoted comments

@shaicantor on my project we decided to go with installing @types/graphql as a dev dependency. The library is deprecated but I was more comfortable with that choice since my code will break once it’s no longer available versus the --skipLibCheck which in my estimation would be harder to remember to revert once the issue is resolved.

Yarn actually checks the engines configuration in your package.json and the package.json of all your dependencies and will fail to install any dependency which does not support your current node version. At least as far as I’m aware, npm does not do this check.

It has been dropped in this PR https://github.com/open-telemetry/opentelemetry-js-contrib/pull/754, we need to find a long term solution for this cc @nata7che