question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

apollo client 2.0.4, how get the store, from new onError , apollo-link-error

See original GitHub issue

I’have migrated from apollo 1, all it’s working well , but just errors, with apollo 1 I used to catch the errors on my mutate action, and inside I had props, to call translate, redux saga and another states to show errors and change the behaviour accord errors. with apollo2 looks different.

my problem is get the state from my redux inside the new onError ;, that is imported with : import { onError } from ‘apollo-link-error’;

const errorLink = onError((Error) => {
  console.log('store',store.getState());  // does not work
  (..)
}

on my app.js

      <ErrorBoundary>
        <Provider store={store} >
          <ApolloProvider client={client}>
            <BrowserRouter>
              <Switch>

i’m doing well have apolloprovider inside Provider(redux) ? this the only thing to send my new project in new version 2 that looks fantastic.

Version “react-apollo”: “2.0.4”,

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
eliasturbaycommented, Dec 24, 2017

@webmobiles you will have to export your store object in app.js like this:

export const store = createStore(
  combineReducers({ ...

then you can just import it where you need it:

import { store } from '../../app';

Best,

0reactions
hwillsoncommented, Aug 5, 2018

This is a React Apollo issue, and is being tracked here: https://github.com/apollographql/react-apollo/issues/1360 (see workaround in https://github.com/apollographql/react-apollo/issues/1360#issuecomment-347556125). Since this is already being tracked in the React Apollo repo, I’ll close it here. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Link - Apollo GraphQL Docs
Use the onError link to perform custom logic when a GraphQL or network error occurs. You pass this link a function that's executed...
Read more >
File Upload with GraphQL, Apollo Server, Hapi 18+, and React
4. Read the file stream and write a file successfully on the server side. Let's get started! Client-side React code with mutation.
Read more >
react-apollo: An approach to handle errors globally
The Apollo client, or the react-apollo binding to be precisely, ... called onError which takes an error object and performs a complete new...
Read more >
apollo-link-error | Yarn - Package Manager
Use this link to do some custom logic when a GraphQL or network error happens: import { onError } from "apollo-link-error"; const link...
Read more >
How to use import { onError } from 'apollo-link-error' in angular ...
Hi and Welcome to Stack Overflow! Do you get any errors in your console? What is the actual behaviour of your current application,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found