We getting following errors, it could be due to @types/graphql happens to be in dependencies rather than in devDependencies.
https://github.com/apollographql/apollo-link/blob/master/packages/apollo-link/package.json#L41
This forcing us to use a version that comes with apollo-link only. Wondering whether anyone caught this thing yet.
graphql-schema/src/__tests__/integration_setup.ts(23,50)
TS2345: Argument of type 'DocumentNode' is not assignable to parameter of type 'DocumentNode'.
Types of property 'loc' are incompatible.
Type 'Location' is not assignable to type 'Location'. Two different types with this name exist, but they are unrelated.
Types of property 'startToken' are incompatible.
Type 'Token' is not assignable to type 'Token'. Two different types with this name exist, but they are unrelated.
Types of property 'kind' are incompatible.
Type 'TokenKind' is not assignable to type '"<SOF>" | "<EOF>" | "!" | "$" | "(" | ")" | "..." | ":" | "=" | "@" | "["| "]" | "{" | "|" | "}"...'.
Type '"BlockString"' is not assignable to type '"<SOF>" | "<EOF>" | "!" | "$" | "(" | ")" | "..." | ":" | "=" | "@"| "[" | "]" | "{" | "|" | "}"...'.
We are seeing this error with incompatible TokenKind vs. BlockString, too. Our project used to declare the following dependencies:
"apollo-cache": "^1.1.7",
"apollo-cache-redux": "0.1.0",
"apollo-client": "^2.2.8",
"apollo-link-http": "^1.5.4",
"graphql": "^0.13.0",
"graphql-anywhere": "^4.1.8",
"graphql-tag": "^2.8.0",
We traced down the type error as follows:
apollo-client requires [email protected]
apollo-link-http requires [email protected]
Starting in version 1.2.2 you now re-export some types from @types/graphql in apollo-link/types.d.ts. Thereby you force the use of your exact version of @types/graphql. The culprit for the type error is the re-exported type DocumentNode. It conflicted with our project's implicit depencency on @types/graphql.
We also use tslint-plugin-graphql which is very handy but has not seen an update in a long time and still has a dependency to version 0.8.6 of @types/graphql. That was the version that ended up being our project's required version.
We don't want to use that old version in our code anyway, so we added an explicit dependency to @types/[email protected] to our project. And we also downgraded graphql itself from 0.13.2 to 0.12.6. That solves the issue for now.
Upgrading to a newer version of graphql and @types/graphql will now have to occur in lockstep with appollo-link. There is no technical issue with this since we exclusively use Apollo to deal with GraphQL. But it also means we depend on you to perform security updates and the like quickly. Meh.
Same error. @kreba's solution worked for us.
Running into the same issue using type-graphql with 2.0.0-rc.6.
Same issue. Installing @types/[email protected] explicitly and manually removing the node_modules folder in apollo-link seems to fix it for me, so apollo-link will also use the top-level type definitions. Any estimate on a fix? Could the GraphQL typing dependency be put into a peer dependency?
This was fixed by https://github.com/apollographql/apollo-link/pull/735. @types/graphql was changed to a devDependency.
For others hitting this, I had to do some yarn cleanup to pick up on the package change and get rid of the type conflicts. rm -rf node_modules/ && yarn cache clean && rm -rf yarn.lock && yarn install
The latest apollo-client and several of the apollo-link-* packages seem to depend on @types/[email protected] also. Does it matter if it's a devDependency if it's still being referenced from and used by exported components?
Unless I manually install @types/[email protected], I still see tons of errors similar to this:
Type 'import("my-project/node_modules/@types/graphql/language/ast").DocumentNode' is not assignable to type 'import("my-project/node_modules/apollo-client/node_modules/@types/graphql/language/ast").DocumentNode'.
Explicit peerDependencies seem like the way to go here.
Most helpful comment
We are seeing this error with incompatible
TokenKindvs.BlockString, too. Our project used to declare the following dependencies:We traced down the type error as follows:
apollo-clientrequires[email protected]apollo-link-httprequires[email protected]Starting in version 1.2.2 you now re-export some types from
@types/graphqlinapollo-link/types.d.ts. Thereby you force the use of your exact version of@types/graphql. The culprit for the type error is the re-exported typeDocumentNode. It conflicted with our project's implicit depencency on@types/graphql.We also use
tslint-plugin-graphqlwhich is very handy but has not seen an update in a long time and still has a dependency to version0.8.6of@types/graphql. That was the version that ended up being our project's required version.We don't want to use that old version in our code anyway, so we added an explicit dependency to
@types/[email protected]to our project. And we also downgradedgraphqlitself from0.13.2to0.12.6. That solves the issue for now.Upgrading to a newer version of
graphqland@types/graphqlwill now have to occur in lockstep withappollo-link. There is no technical issue with this since we exclusively use Apollo to deal with GraphQL. But it also means we depend on you to perform security updates and the like quickly. Meh.