Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tsc error in sample/12-graphql-apollo #1341

Closed
bisque33 opened this issue Dec 5, 2018 · 4 comments
Closed

Tsc error in sample/12-graphql-apollo #1341

bisque33 opened this issue Dec 5, 2018 · 4 comments

Comments

@bisque33
Copy link

bisque33 commented Dec 5, 2018

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

A compile error occurred in sample / 12-graphql-apollo.

Expected behavior

Minimal reproduction of the problem with instructions

$ cd sample/12-graphql-apollo
$ yarn install
yarn install v1.12.3
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning " > @nestjs/graphql@5.4.0" has incorrect peer dependency "graphql@^14.0.0".
[4/4] 📃  Building fresh packages...
success Saved lockfile.
✨  Done in 28.91s.
$ yarn start:prod
yarn run v1.12.3
$ tsc
node_modules/apollo-cache-control/dist/index.d.ts:20:16 - error TS2665: Invalid module name in augmentation. Module 'graphql/type/definition' resolves to an untyped module at '/Users/bisque33/Programs/nest/sample/12-graphql-apollo/node_modules/graphql/type/definition.js', which cannot be augmented.

20 declare module 'graphql/type/definition' {
                  ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/graphql-subscriptions/dist/pubsub-engine.d.ts:5:52 - error TS2304: Cannot find name 'AsyncIterator'.

5     asyncIterator<T>(triggers: string | string[]): AsyncIterator<T>;
                                                     ~~~~~~~~~~~~~

node_modules/graphql-subscriptions/dist/pubsub.d.ts:15:52 - error TS2304: Cannot find name 'AsyncIterator'.

15     asyncIterator<T>(triggers: string | string[]): AsyncIterator<T>;
                                                      ~~~~~~~~~~~~~

node_modules/graphql-subscriptions/dist/with-filter.d.ts:2:94 - error TS2304: Cannot find name 'AsyncIterator'.

2 export declare type ResolverFn = (rootValue?: any, args?: any, context?: any, info?: any) => AsyncIterator<any>;
                                                                                               ~~~~~~~~~~~~~

node_modules/graphql-tools/dist/stitching/makeRemoteExecutableSchema.d.ts:3:109 - error TS2304: Cannot find name 'AsyncIterator'.

3 export declare type ResolverFn = (rootValue?: any, args?: any, context?: any, info?: GraphQLResolveInfo) => AsyncIterator<any>;
                                                                                                              ~~~~~~~~~~~~~

node_modules/subscriptions-transport-ws/dist/server.d.ts:5:41 - error TS2304: Cannot find name 'AsyncIterator'.

5 export declare type ExecutionIterator = AsyncIterator<ExecutionResult>;
                                          ~~~~~~~~~~~~~

node_modules/subscriptions-transport-ws/dist/server.d.ts:42:124 - error TS2304: Cannot find name 'AsyncIterator'.

42 }, operationName?: string, fieldResolver?: GraphQLFieldResolver<any, any>) => ExecutionResult | Promise<ExecutionResult> | AsyncIterator<ExecutionResult>;
                                                                                                                              ~~~~~~~~~~~~~

node_modules/subscriptions-transport-ws/dist/server.d.ts:45:136 - error TS2304: Cannot find name 'AsyncIterator'.

45 }, operationName?: string, fieldResolver?: GraphQLFieldResolver<any, any>, subscribeFieldResolver?: GraphQLFieldResolver<any, any>) => AsyncIterator<ExecutionResult> | Promise<AsyncIterator<ExecutionResult> | ExecutionResult>;
                                                                                                                                          ~~~~~~~~~~~~~

node_modules/subscriptions-transport-ws/dist/server.d.ts:45:177 - error TS2304: Cannot find name 'AsyncIterator'.

45 }, operationName?: string, fieldResolver?: GraphQLFieldResolver<any, any>, subscribeFieldResolver?: GraphQLFieldResolver<any, any>) => AsyncIterator<ExecutionResult> | Promise<AsyncIterator<ExecutionResult> | ExecutionResult>;
                                                                                                                                                                                   ~~~~~~~~~~~~~

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The error was solved by modifying it as follows.

$ git diff
diff --git a/sample/12-graphql-apollo/package.json b/sample/12-graphql-apollo/package.json
index b230f310..14a7bb21 100644
--- a/sample/12-graphql-apollo/package.json
+++ b/sample/12-graphql-apollo/package.json
@@ -12,6 +12,7 @@
     "@nestjs/common": "^5.3.6",
     "@nestjs/core": "^5.3.6",
     "@nestjs/graphql": "^5.3.0",
+    "@types/graphql": "^14.0.3",
     "apollo-server-express": "2.0.4",
     "class-transformer": "^0.1.9",
     "class-validator": "^0.9.1",
diff --git a/sample/12-graphql-apollo/tsconfig.json b/sample/12-graphql-apollo/tsconfig.json
index ea15af49..d9e89eca 100644
--- a/sample/12-graphql-apollo/tsconfig.json
+++ b/sample/12-graphql-apollo/tsconfig.json
@@ -7,6 +7,7 @@
     "noLib": false,
     "emitDecoratorMetadata": true,
     "experimentalDecorators": true,
+    "lib": ["es6", "esnext.asynciterable"],
     "target": "es6",
     "sourceMap": true,
     "allowJs": true,

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

    "@nestjs/common": "^5.3.6",
    "@nestjs/core": "^5.3.6",
    "@nestjs/graphql": "^5.3.0",

https://github.com/nestjs/nest/blob/master/sample/12-graphql-apollo/package.json#L12-L14

For Tooling issues:
- Node version: v10.8.0  
- Platform: Mac  

Others:

@kamilmysliwiec
Copy link
Member

Have you tried updating your TypeScript version?

@beingadrian
Copy link

@kamilmysliwiec Greetings, I can still see the problem that @bisque33 had described, and his proposed fix to include the libs does seem to fix the errors.

Regarding the TypeScript version, I believe the sample code has it as a dependency at version 3.0.3.

@basicBrogrammer
Copy link

I'm running into this issue as well. Has anyone found the answer?
apollographql/graphql-subscriptions#83 (comment)
seems related?

@lock
Copy link

lock bot commented Sep 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants