Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

ApolloLink is missing onError and setOnError properties #51

Open
AdrienLemaire opened this issue May 9, 2020 · 4 comments
Open

ApolloLink is missing onError and setOnError properties #51

AdrienLemaire opened this issue May 9, 2020 · 4 comments

Comments

@AdrienLemaire
Copy link

Currently setting up a new project with:

  • @apollo/client ^3.0.0-beta.44
  • apollo-link-http ^1.5.17
  • apollo-link-persisted-queries ^0.2.2

When setting up APQ, I'm getting this typescript error on missing onError and setOnError properties:

I'm not sure if the issue is on my side (bad configuration) or on the library needing some update to work with apollo client 3.
How do you suggest I resolve this issue?

@AdrienLemaire
Copy link
Author

AdrienLemaire commented May 9, 2020

I've found that the current @apollo/client package has createHttpLink in @apollo/client/link/http/createHttpLink.js

When trying to use this one instead, The onError/setOnError error persists and I'm getting this additional error:

I suppose it's because you're importing from apollo-link in https://github.com/apollographql/apollo-link-persisted-queries/blob/master/src/index.ts#L1 instead of @apollo/client

@AdrienLemaire
Copy link
Author

AdrienLemaire commented May 9, 2020

@hwillson do you know how I can run your branch ac3-updates in my project?

With npm install apollographql/apollo-link-persisted-queries.git#ac3-updates --save

My package.json gets updated to:

  "dependencies": {
    "@apollo/client": "^3.0.0-beta.44",
    "@apollo/link-persisted-queries": "github:apollographql/apollo-link-persisted-queries#ac3-updates",

But since the code is written in typescript and there's no setup triggered to compile to js on npm install, I'm ending with no code available in node_modules

$ ls node_modules/@apollo/link-persisted-queries
appveyor.yml  codecov.yml      dangerfile.ts  package.json  renovate.json     scripts
CHANGELOG.md  CONTRIBUTING.md  LICENSE        README.md     rollup.config.js

Is there a best practice to follow here?

EDIT: for the time being, I've just copied the apollo-link-persisted-queries.ts to my project with a relative import.

@rabinage
Copy link

rabinage commented Jul 6, 2020

Check your import apollo-link-persisted-queries. It should be @apollo/link-persisted-queries
Then you can concat the Link or use from()

import { HttpLink, from } from '@apollo/client';
import { createPersistedQueryLink } from "@apollo/link-persisted-queries";

 const link = from([
   createPersistedQueryLink(),
   new HttpLink({
     uri: '',
   })
 ])

@westonmossman
Copy link

westonmossman commented Aug 1, 2020

@rabinage can this be added to the usage docs here: https://github.com/apollographql/apollo-link-persisted-queries ? It is currently import { createPersistedQueryLink } from "apollo-link-persisted-queries";

Looks like this page needs to be updated as well: https://www.apollographql.com/docs/link/links/http/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants