Request: Simplify apollo-client middleware
See original GitHub issueRight 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:
- Created 7 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
@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.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.