apollographql / graphql-subscriptions

:newspaper: A small module that implements GraphQL subscriptions for Node.js
MIT License
1.59k stars 133 forks source link

Cannot find name 'AsyncIterator' error in Typescript compilation process. #83

Closed ghost closed 7 years ago

ghost commented 7 years ago

I have found a difficulty compiling my Typescript code and it turns out that inside many files in graphql-subscriptions and subscriptions-transport-ws, the AsyncIterator iterator type interface is treated as defined, but the Typescript compiler doesn't agree with that. here is the list of errors:

node_modules/graphql-subscriptions/dist/pubsub-engine.d.ts(5,52): error TS2304: Cannot find name 'AsyncIterator'.
node_modules/graphql-subscriptions/dist/pubsub.d.ts(12,52): error TS2304: Cannot find name 'AsyncIterator'.
node_modules/graphql-subscriptions/dist/with-filter.d.ts(2,94): error TS2304: Cannot find name 'AsyncIterator'.
node_modules/graphql-subscriptions/dist/with-filter.d.ts(3,58): error TS2304: Cannot find name 'AsyncIterator'.
node_modules/subscriptions-transport-ws/dist/server.d.ts(5,41): error TS2304: Cannot find name 'AsyncIterator'.
node_modules/subscriptions-transport-ws/dist/server.d.ts(29,58): error TS2304: Cannot find name 'AsyncIterator'.
node_modules/subscriptions-transport-ws/dist/server.d.ts(32,31): error TS2304: Cannot find name 'AsyncIterator'.

screenshot 22

I had found a temporary solution to bypass the errors by defining AsyncIterator type interface in every file involved in node_modules, here is the definition:

interface AsyncIterator<T> {
  next(value?: any): Promise<IteratorResult<T>>;
  return?(value?: any): Promise<IteratorResult<T>>;
  throw?(e?: any): Promise<IteratorResult<T>>;
}

screenshot 23

veeramarni commented 7 years ago

Thanks for the workaround, I was having the same issue and adding the missing types have fixed the problem. But this is just a workaround, and it seems like those interfaces need to be in this project.

veeramarni commented 7 years ago

I think we can use esnext lib to fix this issue. See below link

https://github.com/apollographql/graphql-subscriptions/issues/77

ghost commented 7 years ago

Thanks!! By adding:

 "compilerOptions": {
   "lib": [
      "esnext.asynciterable"
    ],
. . .

to tsconfig.json file fixed the issue for good.

Parziphal commented 7 years ago

If I add the lib array to compilerOptions, I get hundreds of errors because everything breaks (even Date becomes unavailable). Adding the interface to the files where the error occurs fixed the problem.

comonadd commented 7 years ago

@Parziphal, agree.

I think this problem is there because of the fact that TypeScript has the default "lib" option defined somewhere in the code.

So, in order to fix that problem, you need to include all of the libraries that "lib" option contains by default. Those are:

"es5",
"es6",
"dom",
"es2015.core",
"es2015.collection",
"es2015.generator",
"es2015.iterable",
"es2015.promise",
"es2015.proxy",
"es2015.reflect",
"es2015.symbol",
"es2015.symbol.wellknown",
"esnext.asynciterable"

So, this solves the problem, - you just need to set the "lib" TypeScript compiler option to the array of default libraries concatenaed with the "esnext.asynciterable" library, like this:

{
  "compilerOptions": {
    // ...
    "lib": [
      "es5",
      "es6",
      "dom",
      "es2015.core",
      "es2015.collection",
      "es2015.generator",
      "es2015.iterable",
      "es2015.promise",
      "es2015.proxy",
      "es2015.reflect",
      "es2015.symbol",
      "es2015.symbol.wellknown",
      "esnext.asynciterable"
    ]
  },
  // ...
}
ghost commented 7 years ago

But the problem is, you have to make that change after every npm install...

joseluisq commented 7 years ago

That works! :+1:

tal commented 7 years ago

Hrm, adding the big list of options to lib didn't work for me. I got a bunch of other errors

node_modules/apollo-client/transport/afterware.d.ts(4,15): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/afterware.d.ts(5,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/afterware.d.ts(11,16): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/afterware.d.ts(12,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(8,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(11,16): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(12,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(22,20): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/batchedNetworkInterface.d.ts(36,12): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/middleware.d.ts(5,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/middleware.d.ts(12,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(35,12): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(43,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(46,15): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/networkInterface.d.ts(47,14): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(54,12): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(55,49): error TS2304: Cannot find name 'RequestInit'.
node_modules/apollo-client/transport/networkInterface.d.ts(63,77): error TS2304: Cannot find name 'Response'.
node_modules/apollo-client/transport/networkInterface.d.ts(70,12): error TS2304: Cannot find name 'RequestInit'.
comonadd commented 7 years ago

I should also note that the default library list changes when compilerOptions.target gets changed.

So, you should probably go here, find --lib option, and look at the defaults which fit your needs.

daniele-zurico commented 7 years ago

Hi guys I'm having the same problem: ERROR in /Users/danielezurico/Downloads/angular-graphql-master/quickstart-with-apollo/node_modules/@types/graphql/subscription/subscribe.d.ts (17,4): Cannot find name 'AsyncIterator'. ERROR in /Users/danielezurico/Downloads/angular-graphql-master/quickstart-with-apollo/node_modules/@types/graphql/subscription/subscribe.d.ts (29,4): Cannot find name 'AsyncIterable'.

I tried to add "lib": [ "es5", "es6", "dom", "es2015.core", "es2015.collection", "es2015.generator", "es2015.iterable", "es2015.promise", "es2015.proxy", "es2015.reflect", "es2015.symbol", "es2015.symbol.wellknown", "esnext.asynciterable" ] my package.json is: https://github.com/graphcool-examples/angular-graphql/blob/master/quickstart-with-apollo/package.json

ErbolLab commented 7 years ago

I also faced with the same issue:

adding "esnext" to the "lib" fixed my problem. "lib": ["es6", "dom", "esnext"],

https://github.com/graphcool-examples/angular-graphql/pull/8/files

adrianmoya commented 7 years ago

I also hit this issue twice. The first time adding the extra libs worked. The second time it didn't. I'm trying to run this example https://github.com/scaphold-io/angular4-apollo-client-starter-kit but no luck with the workaround. Is this going to be fixed in some way?

mpicard commented 7 years ago

This has become a major annoyance for me as well, having 'fixed' it a while ago but now it seems to be an issue again and no combination of "lib": [...] seems to work now

flosky commented 7 years ago

+1 for major annoyance!

flosky commented 7 years ago

This is becoming a real blocker now!

I have added the lib stuff to the tsconfig.json and it compiles without error. But now I am loading another module via package.json that we have written ourselves (which compiles itself without errors) and it breaks the npm install with the same AsyncIterator Error.

So each projects compiles without errors, but when I import the other project then the build fails. What is going on here?

Is there a fix on the way? It's been a couple of months now

ghost commented 7 years ago

@flosky: could you be more specific with some code snippets maybe I can help..

flosky commented 7 years ago

Sure, thanks for the help.

My main project uses the serverless package, which also includes the graphql types. I am not actually using them, thats why this is even more frustrating. I was running into the error when trying to transpile my code. I then followed the workaround suggestions and it worked. Here is the tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitAny": false,
    "removeComments": true,
    "preserveConstEnums": true,
    "outDir": "build",
    "allowJs": true,
    "target": "es2015",
    "sourceMap": true,
    "baseUrl": "./",
    "paths": {
      "*": [ "node_modules/@types/*", "*"]
    },
    "lib": [
      "es5",
      "es6",
      "dom",
      "es2015.core",
      "es2015.collection",
      "es2015.generator",
      "es2015.iterable",
      "es2015.promise",
      "es2015.proxy",
      "es2015.reflect",
      "es2015.symbol",
      "es2015.symbol.wellknown",
      "esnext.asynciterable"
    ]
  },
  "exclude": [
    "node_modules",
    "coverage",
    "build",
    ".git"
  ]
}

I also have another project (a logger module) that I would like to include into my main project. It is not affected by the bug here. I add the dependency to my my main projects package.json as a git link, like this:

"logger": "git+https://<secret>-oauth-basic@github.com/xyz/logger.git#1.1.1"

the logger module runs tsc on postinstall. Now when I run npm install on my main project, I get this error message:

> spawn-sync@1.0.15 postinstall /Users/flo/Workspace/stockLoader/node_modules/spawn-sync
> node postinstall

> logger@1.1.2 postinstall /Users/flo/Workspace/stockLoader/node_modules/logger
> tsc lib/index.ts --outDir build/lib -d --pretty

17 ): AsyncIterator<ExecutionResult>;
      ~~~~~~~~~~~~~

../@types/graphql/subscription/subscribe.d.ts(17,4): error TS2304: Cannot find name 'AsyncIterator'.

/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:2062
            throw e;
            ^

Error: Debug Failure. False expression.
    at computePositionOfLineAndCharacter (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:3752:22)
    at Object.getPositionOfLineAndCharacter (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:3742:16)
    at Object.formatDiagnosticsWithColorAndContext (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:55575:59)
    at reportDiagnosticWithColorAndContext (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:58771:25)
    at reportDiagnostic (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:58733:9)
    at reportDiagnostics (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:58738:13)
    at compileProgram (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:59099:13)
    at compile (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:59051:26)
    at performCompilation (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:58940:33)
    at Object.executeCommandLine (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:58883:9)
    at Object.<anonymous> (/Users/flo/Workspace/stockLoader/node_modules/typescript/lib/tsc.js:59241:4)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/flo/Workspace/stockLoader/node_modules/typescript/bin/tsc:2:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:504:3

When I transpile the logger module directly, in its own repo then it works without problems. I only get this error when I reference the dependency in my main project.

ghost commented 7 years ago

@flosky did you add "esnext.asynciterable" to the "lib" attribute in ts.config file of logger module?

flosky commented 7 years ago

@ibraback Yes, I have. At first I removed it and it also worked as it is not using any types from graphql. But I have also added it again (the tsconfig.json is the same as I posted above), pushed the tag again, referenced the new tag in my main project, ran npm install again but same error

ghost commented 7 years ago

@flosky try to add --lib esnext.asynciterable parameter to the tsc lib/index.ts --outDir build/lib -d --pretty command.

flosky commented 7 years ago

@ibraback thanks it sort of worked. I had to add some more libs to make it work. This is my code: "postinstall": "tsc lib/index.ts --outDir build/lib -d --pretty --lib es2015,dom,esnext.asynciterable",.

But what is the timeline to have this fixed?

ghost commented 7 years ago

@flosky since adding esnext.asynciterable to tsconfig file fixed the problem for the majority I don't think there is something to add/fix, but always upgrade your dependencies just in case...

leebenson commented 6 years ago

FWIW, the only fix that worked for me was this exact tsconfig.json:

TL;DR: the only thing in lib is esnext -- esnext.asynciterable alone yielded the following error:

error TS2318: Cannot find global type 'Boolean'. error TS2318: Cannot find global type 'Function'. error TS2318: Cannot find global type 'Number'. error TS2318: Cannot find global type 'Object'. error TS2318: Cannot find global type 'RegExp'.

{
  "compilerOptions": {
    /* Basic Options */
    "target": "ES2017",                       /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
    "lib": [                                  /* Specify library files to be included in the compilation:  */
      "esnext"
    ],                             
    // "allowJs": true,                       /* Allow javascript files to be compiled. */
    // "checkJs": true,                       /* Report errors in .js files. */
    // "jsx": "preserve",                     /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
    // "declaration": true,                   /* Generates corresponding '.d.ts' file. */
    // "sourceMap": true,                     /* Generates corresponding '.map' file. */
    // "outFile": "./",                       /* Concatenate and emit output to single file. */
    "outDir": "./dist",                        /* Redirect output structure to the directory. */
    // "rootDir": "./",                       /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
    "removeComments": true,                /* Do not emit comments to output. */
    // "noEmit": true,                        /* Do not emit outputs. */
    // "importHelpers": true,                 /* Import emit helpers from 'tslib'. */
    // "downlevelIteration": true,            /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
    // "isolatedModules": true,               /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

    /* Strict Type-Checking Options */
    "strict": true,                            /* Enable all strict type-checking options. */
    // "noImplicitAny": true,                 /* Raise error on expressions and declarations with an implied 'any' type. */
    // "strictNullChecks": true,              /* Enable strict null checks. */
    // "noImplicitThis": true,                /* Raise error on 'this' expressions with an implied 'any' type. */
    // "alwaysStrict": true,                  /* Parse in strict mode and emit "use strict" for each source file. */

    /* Additional Checks */
    "noUnusedLocals": true,                /* Report errors on unused locals. */
    "noUnusedParameters": true            /* Report errors on unused parameters. */
    // "noImplicitReturns": true,             /* Report error when not all code paths in function return a value. */
    // "noFallthroughCasesInSwitch": true,    /* Report errors for fallthrough cases in switch statement. */

    /* Module Resolution Options */
    // "moduleResolution": "node",            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
    // "baseUrl": "./",                       /* Base directory to resolve non-absolute module names. */
    // "paths": {},                           /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
    // "rootDirs": [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */
    // "typeRoots": [],                       /* List of folders to include type definitions from. */
    // "types": [],                           /* Type declaration files to be included in compilation. */
    // "allowSyntheticDefaultImports": true,  /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
    // "preserveSymlinks": true,              /* Do not resolve the real path of symlinks. */

    /* Source Map Options */
    // "sourceRoot": "./",                    /* Specify the location where debugger should locate TypeScript files instead of source locations. */
    // "mapRoot": "./",                       /* Specify the location where debugger should locate map files instead of generated locations. */
    // "inlineSourceMap": true,               /* Emit a single file with source maps instead of having a separate file. */
    // "inlineSources": true,                 /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

    /* Experimental Options */
    // "experimentalDecorators": true,        /* Enables experimental support for ES7 decorators. */
    // "emitDecoratorMetadata": true,         /* Enables experimental support for emitting type metadata for decorators. */
  }
}
motss commented 6 years ago

This works for me: tsc index.ts --lib esnext,esnext.asynciterable

eajitesh commented 6 years ago

There are two tsconfig.json (one in root folder and another in src/ folder) files when working with an Angular app installed with CLI. The problem gets fixed when I put "esnext" within src/tsconfig.json:

"lib": [ "es2015", "dom", "esnext" ]

mbrowne commented 6 years ago

Just adding esnext.asynciterable worked for me:

"lib": ["es6", "esnext.asynciterable", "dom"],
jspri commented 6 years ago

Is this a problem with the original definition file? Do asynciterables need to exist in the runtime? Is there a polyfill somewhere? Is there a way this could be changed so that it just works?

mbrowne commented 6 years ago

The AsyncIterator type is used in the code for this repo, so my guess is that this would need to be updated on the TypeScript end. Async iterators are already a stage 3 proposal for ECMAScript, which hopefully means TypeScript will add support for them by default soon, but since they require in-browser support as well I'm not sure; maybe it will take much longer. Perhaps someone here can point you to more info on this, or you could search discussions in the TypeScript repo.

jspri commented 6 years ago

My local environment (node 6) doesn't yet support AsyncIterables so I believe putting it in tsconfig:lib is incorrect and could lead to other parts of the project compiling when they shouldn't.

This project should define AsyncIterator with a compatible definition instead of relying on the definition from the library. This will also make less peoples projects break when they use your project.

mbrowne commented 6 years ago

I am not a contributor to this library so this is not official advice, but if I were you I would create a new issue about this (with a link to this one) rather than waiting for this issue to be reopened.

ghost commented 6 years ago

I had a similar issue. I was trying to integrate Apollo in typescript project using awesome typescript loader which turned out to be the source of the problem. After switching back to ts-lint loader all worked nice. However, using the (a bit optimised) solution from mbrowne did the trick also with awesome typescript loader, but I don't like extra configs just to please an issue :)

yuhr commented 6 years ago

Thanks to @leebenson. All I had to have was only "esnext".

mbrowne commented 6 years ago

Note that there is a small risk with using "esnext" instead of "esnext.asynciterable" specifically: "esnext" will allow you to use any new JS features supported by TypeScript regardless of whether or not you have a polyfill for them. So be mindful of which ES2016+ features you're using and use something like https://polyfill.io if you want broad browser support.

dsebastien commented 6 years ago

I stumbled upon this issue while trying the hello world tutorial for Apollo with TypeScript. Indeed just adding esnext.asynciterable fixed the issue

vksgautam1 commented 6 years ago
 "esnext.asynciterable"

including it giving me error

" let wopt: WatchQueryOptions; wopt = { fetchPolicy: 'network-only',//FetchPolicy,//'cache-and-network', query: type, variables: params } this.apollo. watchQuery(wopt) .valueChanges .subscribe((val) => { }

(in promise): TypeError: Object(...) is not a function TypeError: Object(...) is not a function"

danielpza commented 6 years ago

tsconfig.json

"lib": [
  // "esnext"
  "esnext.asynciterable"
],
$ tsc -p .
error TS2318: Cannot find global type 'Boolean'.
error TS2318: Cannot find global type 'Function'.
error TS2318: Cannot find global type 'Number'.
error TS2318: Cannot find global type 'Object'.
error TS2318: Cannot find global type 'RegExp'.
ooade commented 6 years ago

@danielpa9708 just esnext alone saves the day. But don't know if there's any performance loss by doing that.

schmidsi commented 6 years ago

I had the same problem and the following change to tsconfig.json did the trick:

Example tsconfig.json:

{
  "compilerOptions": {
    "outDir": "./dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "module": "commonjs",
    "target": "es5",
    "skipLibCheck": true,
    "jsx": "react"
  },
  "include": [
    "./src/**/*"
  ],
  "lib": [
    "esnext",
  ],
}
charlieg-nuco commented 6 years ago

I'm just getting started with typescript and I got this issue. Only I was missing AsyncIterable as well. Adding that interface gets rid of the compilation error but there has to be a more elegant fix.

niba commented 6 years ago

@schmidsi your config file has the error, lib should be inside compilerOptions. The correct configuration is

{
  "compilerOptions": {
    "outDir": "./dist/",
    "sourceMap": true,
    "noImplicitAny": true,
    "module": "commonjs",
    "target": "es5",
    "skipLibCheck": true,
    "jsx": "react",
    "lib": [
       "esnext",
     ],
  },
  "include": [
    "./src/**/*"
  ],

}

Probably after this fix you don't need to set the skipLibCheck to true anymore

Morphexe commented 5 years ago

None of the solutions work :) Adding EsNext does nothing for me, throws the error on browser.

grantwwu commented 5 years ago

Can you post your tsconfig.json?

brianschardt commented 5 years ago

same issue as Morphexe heres my file { "compilerOptions": { "target": "es6", "lib": [ "es5", "es6", "dom", "es2015.core", "es2015.collection", "es2015.generator", "es2015.iterable", "es2015.promise", "es2015.proxy", "es2015.reflect", "es2015.symbol", "es2015.symbol.wellknown", "esnext.asynciterable" ], "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "declaration": false, "outDir": "dist", "typeRoots": ["node_modules/@types"] }, "files": ["src/app.ts"], "exclude": ["node_modules"] }

grantwwu commented 5 years ago

Try "esModuleInterop": true as an entry in compilerOptions

brianschardt commented 5 years ago

@grantwwu thanks for the quick response. Tried that did not work Here is the repo I want to run tsc src/app.ts

https://github.com/brianalois/node_graphql_apollo_template

grantwwu commented 5 years ago

I believe that if you try to compile a particular file, it does not use your tsconfig.json. Try just running tsc at the root of your project. I was able to compile it fine there, after npm install --save-dev @graphql/types

switch120 commented 5 years ago

Holy crap ... @grantwwu that was the fix for me too; just don't specify a .ts file. I would never have just tried that. Ugh!

zgldh commented 5 years ago
// Polyfill Symbol.asyncIterator
(Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol("Symbol.asyncIterator");

https://stackoverflow.com/questions/43258568/for-await-of-simple-example-typescript

ilyaskarim commented 5 years ago

Installing Graphql types solved my case:

npm install --save-dev @types/graphql

akomm commented 4 years ago

Note that there is a small risk with using "esnext" instead of "esnext.asynciterable" specifically: "esnext" will allow you to use any new JS features supported by TypeScript regardless of whether or not you have a polyfill for them. So be mindful of which ES2016+ features you're using and use something like https://polyfill.io if you want broad browser support.

The only sane reply here. The question is, whether the graphql library uses the feature or just produces a polyfilled fake of the interface. If the later is the case, adding es2018.asynciterable or esnext.asynciterable to lib in tsconfig.json is okay. If the former is the case, you need to polyfill the feature.