Apollo-client: Argument of type '{ link: ApolloLink; }' is not assignable to parameter of type 'PresetConfig'

Created on 8 Jun 2018  路  3Comments  路  Source: apollographql/apollo-client

Intended outcome:
Using the sample in the docs to add authorization header to a query.

The code does not compile when using TypeScript because the PresetConfig interface does not contain a definition for an ApolloLink member.

export interface PresetConfig {
    request?: (operation: Operation) => Promise<void>;
    uri?: string;
    fetchOptions?: HttpLink.Options;
    clientState?: ClientStateConfig;
    onError?: ErrorLink.ErrorHandler;
    cacheRedirects?: CacheResolverMap;
}

Actual outcome:
The sample code does not compile, the following error is reported:

    TS2345: Argument of type '{ link: ApolloLink; }' is not assignable to parameter of type 'PresetConfig'.
  Object literal may only specify known properties, and 'link' does not exist in type 'PresetConfig'.

How to reproduce the issue:
Simply try the code sample in a typescript project.

Versions

System:
OS: macOS High Sierra 10.13.4
Binaries:
Node: 8.11.2 - /usr/local/bin/node
Yarn: 1.2.0 - /usr/local/bin/yarn
npm: 5.6.0 - /usr/local/bin/npm
Browsers:
Chrome: 67.0.3396.79
Safari: 11.1
npmPackages:
apollo-boost: ^0.1.7 => 0.1.7
apollo-link-context: ^1.0.8 => 1.0.8

Issue Labels

  • [ X] has-reproduction
  • [ ] feature
  • [ ] docs
  • [ X] blocking
  • [ ] good first issue

Most helpful comment

For reference, it should be imported from the apollo-client package:

import { ApolloClient } from 'apollo-client';

All 3 comments

Sorry I was using ApolloClient from apollo-boost package...

For reference, it should be imported from the apollo-client package:

import { ApolloClient } from 'apollo-client';

apollo-boost to apollo-client migration procedure : https://www.apollographql.com/docs/react/migrating/boost-migration/

Was this page helpful?
0 / 5 - 0 ratings