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.

Request: Simplify apollo-client middleware

See original GitHub issue

Right now we have to do something like this:

networkInterface.use([{
  applyMiddleware(request, next) {
    if (!request.options.headers) {
      request.options.headers = new Headers();
    }
    request.options.headers.Authorization = token;
    next();
  }
}]);

It would be much nicer to be able to provide regular functions to networkInterface.use rather than having to use applyMIddleware. Thoughts?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
czbakercommented, May 28, 2016

@zimme: Exactly. When I was trying to figure out middleware, since I needed it for authorization in my current project, I looked to the Express middleware docs for help, as it was undocumented here.

I was super confused when I realized that it wasn’t the same, and that there was an applyMiddleware requirement that I was unaware of.

0reactions
helfercommented, Jan 26, 2017

cc @DxCx @calebmer if we overhaul the network interface, we should keep this in mind. I’m closing it now since it’s an ancient issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced HTTP networking - Apollo GraphQL Docs
Apollo Client uses HttpLink to send GraphQL operations to a server over HTTP. The link supports both POST and GET requests, and it...
Read more >
Why Apollo Client? - Apollo GraphQL Docs
Apollo Client handles the request cycle from start to finish, including tracking loading and error states. There's no middleware or boilerplate code to...
Read more >
Using Apollo Link to Handle Dependent Queries
Option 3: Use Apollo Link to automatically read the value from previous queries and pass it to dependent queries. The solution above solves...
Read more >
Configuring CORS - Apollo GraphQL Docs
You can also choose to omit CORS middleware entirely to disable cross-origin requests. This is recommended for subgraphs in a federated graph.
Read more >
Network layer (Apollo Link) - Apollo GraphQL Docs
Apollo Link is designed from day one to be easy to use middleware on your requests. Middlewares are used to inspect and modify...
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