[Network error]: TypeError: forward is not a function
See original GitHub issueI tried to use Error Link as in document’s example
const link = onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors)
graphQLErrors.map(({ message, locations, path }) =>
console.log(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
)
)
if (networkError) console.log(`[Network error]: ${networkError}`)
})
const apolloClient = new ApolloClient({
uri: '/graphql',
cache: new InMemoryCache(),
link: ApolloLink.from([link])
})
but got the following in the console.
[Network error]: TypeError: forward is not a function
After some try, I found adding HttpLink would work
const apolloClient = new ApolloClient({
cache: new InMemoryCache(),
link: ApolloLink.from([link, new HttpLink({uri: '/graphql'})])
})
Probably worth mention it in the doc.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:31
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Querying graphiql leads Apollo error forward is not a function
When executing the above mentioned query without the link variable that handles the error, I receive a 400 Bad Request from the server...
Read more >Error Link - Apollo GraphQL Docs
A function that calls the next link down the chain. Calling return forward(operation) in your onError callback retries the operation, returning a new...
Read more >apollo-link.forward JavaScript and Node.js code examples
Best JavaScript code snippets using apollo-link.forward(Showing top 13 results out ... function createClient(headers, token, initialState) { let accessToken ...
Read more >TypeError: forward is not a function @apollo/client@3.0.0-beta ...
Expected Behavior When using onError() from @apollo/link-error we do not get an error upon GraphQL request. Actual Behavior.
Read more >How to use the apollo-link.ApolloLink function in apollo-link
{ graphqlErrors, networkError }); }); const authLink = new ApolloLink((operation, forward) => { const token = localStorage.getItem('AUTH_TOKEN'); operation.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Same issue here. The example in the Docs seems “unfinished” in how ApolloClient 3 expects us to handle onError.
Seems like you need to do:
It seems that the errorLink must not be the first link in the chain. I’ve moved the error link between my authentication and http link and the error disappeared.
Is this behavior intentional or is it a bug?