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.

Network error after first GraphQL request

See original GitHub issue
  • I’m submitting a … [ ] bug report [ ] feature request [ ] question about the decisions made in the repository [*] question about how to use this project

  • Summary When I try to use the apollo-link-scalars as advised in the README I get following error after I try to do first GraphQL query:

Uncaught (in promise) Error: Network error: operation.getContext is not a function
    at new ApolloError (bundle.esm.js:76)
    at bundle.esm.js:1469

My apollo client setup is following:

const cache = new InMemoryCache()

const schemaDocument = loader('../common/schema.graphql')

const link = ApolloLink.from([
  withScalars({
    schema: buildASTSchema(schemaDocument),
    typesMap: { DateTime: GraphQLDateTime }
  }),
  new HttpLink()
])

const client = new ApolloClient({
  cache,
  link
})

The error disappears when the apollo-scalars-link is removed.

I’m have an application created by Create React App.

Let me know if there’s any other information I can provide, however this is all I know right now.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
JakubPetriskacommented, Dec 6, 2019

This works now. Thank you very much!!!

2reactions
eturinocommented, Dec 5, 2019

for more info, it was a silly mistake in the serialization process, which replaced the original operation with a new object with the serialized variables… but it lost the prototype in the process. That meant that the getContext function was not there anymore. 🤦‍♂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling operation errors - Apollo GraphQL Docs
When a network error occurs, Apollo Client adds it to the error.networkError field returned by your useQuery call (or whichever operation hook you...
Read more >
Top GraphQL Errors and How to fix them
When there is a network error while trying to contact a GraphQL server, ... there is a possibility of a request containing an...
Read more >
Network Error when initiating a query to my graphql API
Here's my client request : const client = new ApolloClient({ uri: 'https://my-app.herokuapp.com/', headers: { authorization: "Bearer API_KEY ...
Read more >
Handling GraphQL errors like a champ with unions and ...
When GraphQL was gaining popularity, I remember a meme made of some ... time to first byte, slow network requests, and also logs...
Read more >
Five Common Problems in GraphQL Apps (And How to Fix ...
One of the first things you realize when coding a GraphQL back-end ... we still have one initial database call to get the...
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