Apollo-client: Cannot find Response and RequestInit

Created on 23 Mar 2017  Â·  20Comments  Â·  Source: apollographql/apollo-client

After i upgraded to @angular 2.4.10 and @angular/cli to 1.0.0.rc4
/apollo-client/transport/afterware.d.ts (11,16): Cannot find name 'Response'.
/apollo-client/transport/batchedNetworkInterface.d.ts (9,14): Cannot find name 'RequestInit'.)

It was running fine before

Most helpful comment

@Purus Sorry for the delay, only saw your comment now.

I've added "@types/isomorphic-fetch": "0.0.33" to devDependencies in my package.json and

    "types": [
      "isomorphic-fetch"
    ]

to my tsconfig.json, right below "typeRoots".

Nothing different from the regular way of adding types to an Angular CLI app.

Hope it helps.

All 20 comments

Same issue for the below setup.

Ionic Framework: 2.3.0
Ionic App Scripts: 1.1.4
Angular Core: 2.4.8
Angular Compiler CLI: 2.4.8
Node: 6.10.1
OS Platform: Windows 10
Navigator Platform: Win32

I can confirm upgrading @angular/cli to 1.0.0.rc4 throws a couple type errors on build:

/apollo-client/transport/networkInterface.d.ts (60,77): Cannot find name 'Response'.
/apollo-client/transport/networkInterface.d.ts (67,12): Cannot find name 'RequestInit'.

/apollo-client/transport/middleware.d.ts (12,14): Cannot find name 'RequestInit'.

/apollo-client/transport/batchedNetworkInterface.d.ts (12,16): Cannot find name 'Response'.
/apollo-client/transport/batchedNetworkInterface.d.ts (13,14): Cannot find name 'RequestInit'.

/apollo-client/transport/afterware.d.ts (11,16): Cannot find name 'Response'.
/apollo-client/transport/afterware.d.ts (12,14): Cannot find name 'RequestInit'.

Solved it by installing @types/isomorphic-fetch and adding isomorphic-fetch to the types array in tsconfig.json.

Don't know if its an workaround or an actual fix, but there it is..

Can we solve this by adding a dependency on those typings in this package?

I'd suggest waiting to see if it solves the others' issues, it could be a dependency I have due to any other module, although it seems unlikely.

Can you share what you have in package.json and tsconfig.json so that I can try your fix.

@jsfrocha Can you share what changes you have done to package.json and tsconfig.json files?

@Purus Sorry for the delay, only saw your comment now.

I've added "@types/isomorphic-fetch": "0.0.33" to devDependencies in my package.json and

    "types": [
      "isomorphic-fetch"
    ]

to my tsconfig.json, right below "typeRoots".

Nothing different from the regular way of adding types to an Angular CLI app.

Hope it helps.

Thanks @jsfrocha . It works fine now.

Below is the settings for my Ionic app that worked as you have specified. Hope it helps someone else.

// tsconfig.json 
{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5",
    "types": [
      "isomorphic-fetch"
    ]
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

And

packages.json
 .....
  "devDependencies": {
    "@ionic/app-scripts": "1.1.4",
    "typescript": "2.0.9",
    "@types/isomorphic-fetch": "0.0.33"
  },
....

I've upgraded my app to Angular 4 and still have this problem, even when including isomorphic-fetch that @Purus and @jsfrocha describe.

After upgrading I don't face issue even without using the above hack.

On Apr 9, 2017 7:27 PM, "Ahmed" notifications@github.com wrote:

I've upgraded my app to Angular 4 and still have this problem, even when
including isomorphic-fetch that @Purus https://github.com/Purus and
@jsfrocha https://github.com/jsfrocha describe.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/apollographql/apollo-client/issues/1478#issuecomment-292787408,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABBx528iDumXlWmCbnBQwOaAP85bhe59ks5ruOO9gaJpZM4MmQSB
.

@Purus see my screenshot(s) below

image

image

Ok I just came up with a fix.

I was adding the isomorphic-fetch to my tsconfig.json at the root of my directory.

Instead I added it to the tsconfig.app.json inside my src directory and it works fine now.

Screenshot for reference:

image

Looks like this issue is solved with @viztastic 's solution! :tada:

This or something very similar still appears to be a problem here.

ng --version
angular-cli: 1.0.0-beta.28.3
node: 6.11.0
os: win32 x64

TypeScript 2.3.4

I've followed the instructions for getting started on
http://dev.apollodata.com/angular2/initialization.html
followed by
http://dev.apollodata.com/angular2/queries.html

"ng serve" gives the following errors listed below. "ng build --prod" gives even more.
I've tried @viztastic 's solution with no luck.

ERROR in C:....../node_modules/apollo-client/transport/afterware.d.ts (4,15): Cannot find name 'Response'.

ERROR in C:....../node_modules/apollo-client/transport/afterware.d.ts (5,14): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/afterware.d.ts (11,16): Cannot find name 'Response'.

ERROR in C:....../node_modules/apollo-client/transport/afterware.d.ts (12,14): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/batchedNetworkInterface.d.ts (8,14): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/batchedNetworkInterface.d.ts (11,16): Cannot find name 'Response'.

ERROR in C:....../node_modules/apollo-client/transport/batchedNetworkInterface.d.ts (12,14): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/batchedNetworkInterface.d.ts (22,20): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/batchedNetworkInterface.d.ts (36,12): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/middleware.d.ts (5,14): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/middleware.d.ts (12,14): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/networkInterface.d.ts (35,12): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/networkInterface.d.ts (43,14): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/networkInterface.d.ts (46,15): Cannot find name 'Response'.

ERROR in C:....../node_modules/apollo-client/transport/networkInterface.d.ts (47,14): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/networkInterface.d.ts (54,12): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/networkInterface.d.ts (55,49): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/transport/networkInterface.d.ts (63,77): Cannot find name 'Response'.

ERROR in C:....../node_modules/apollo-client/transport/networkInterface.d.ts (70,12): Cannot find name 'RequestInit'.

ERROR in C:....../node_modules/apollo-client/core/types.d.ts (17,45): ',' expected.

ERROR in C:....../node_modules/apollo-client/core/types.d.ts (17,47): '>' expected.

ERROR in C:....../node_modules/apollo-client/core/types.d.ts (19,2): ';' expected.

ERROR in C:....../node_modules/apollo-client/core/types.d.ts (19,4): Expression expected.

ERROR in C:....../node_modules/apollo-client/core/types.d.ts (20,10): Expression expected.

ERROR in C:....../node_modules/apollo-client/core/types.d.ts (20,5): Cannot find name 'data'.

ERROR in C:....../node_modules/apollo-client/core/types.d.ts (20,12): Cannot find name 'T'.

ERROR in C:....../node_modules/apollo-client/data/mutationResults.d.ts (8,48): ',' expected.

ERROR in C:....../node_modules/apollo-client/data/mutationResults.d.ts (8,50): '>' expected.

ERROR in C:....../node_modules/apollo-client/data/mutationResults.d.ts (10,2): ';' expected.

ERROR in C:....../node_modules/apollo-client/data/mutationResults.d.ts (10,4): Expression expected.

ERROR in C:....../node_modules/apollo-client/data/mutationResults.d.ts (11,15): ',' expected.

ERROR in C:....../node_modules/apollo-client/data/mutationResults.d.ts (11,24): ';' expected.

ERROR in C:....../node_modules/apollo-client/data/mutationResults.d.ts (11,49): '(' expected.

ERROR in C:....../node_modules/apollo-client/data/mutationResults.d.ts (11,6): Cannot find name 'queryName'.

ERROR in C:....../node_modules/apollo-client/data/mutationResults.d.ts (11,17): Cannot find name 'string'.

ERROR in C:....../node_modules/apollo-client/data/mutationResults.d.ts (11,26): Cannot find name 'MutationQueryReducer'.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (47,36): ',' expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (47,38): '>' expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (49,2): Expression expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (50,27): ',' expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (51,23): ',' expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (52,43): ',' expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (53,48): '(' expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (54,51): ',' expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (55,34): '(' expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (57,41): ',' expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (57,43): '>' expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (59,2): ';' expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (59,4): Expression expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (59,74): Expression expected.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (50,15): Cannot find name 'DocumentNode'.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (52,26): The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (52,35): The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (53,21): Cannot find name 'MutationQueryReducersMap'.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (54,22): Cannot find name 'string'.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (54,33): Cannot find name 'PureQueryOptions'.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (55,14): Cannot find name 'MutationUpdaterFn'.

ERROR in C:....../node_modules/apollo-client/core/watchQueryOptions.d.ts (59,63): Cannot find name 'T'.

ERROR in C:....../node_modules/apollo-angular/build/src/Apollo.d.ts (14,24): Generic type 'MutationOptions' requires 1 type argument(s).

ERROR in C:....../node_modules/@types/isomorphic-fetch/index.d.ts (8,30): Cannot find name 'fetch'.

Have you fixed the problem ?

Hi @anasvn
No I haven't.
Having repeated my steps and got the same problem, I now wonder if the two steps I completed are actually enough for a Hello World type test. Can anyone enlighten me?
I just want the minimum steps to run the Angular Apollo Client against a GraphQL playground url.
Cheers
Tom

I have solved it by installing the exact version of apollo-client I wanted. My current version where replaced with latest version. I think you could solve it by checking the apollo-client version and re installing it.

Hi @anasvn
Excellent. I will have a go.
Can I ask what versions of Angular, CLI, and apollo-client you've got working?

@TomWhiteCSL I have been using apollo-client 1.4.2 version

Was this page helpful?
0 / 5 - 0 ratings