Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs on adopting middleware #79

Open
nirvdrum opened this issue Oct 23, 2019 · 3 comments
Open

Add docs on adopting middleware #79

nirvdrum opened this issue Oct 23, 2019 · 3 comments

Comments

@nirvdrum
Copy link
Contributor

I may just be really dense, but hopefully this feedback is helpful. I've been using Relay with a fetchQuery function as detailed in the Relay docs. Now I'd like to add an Authorization header and came across this project to do so. Given it's middleware, I'd expect to set it up to wrap my fetchQuery function, but there's no indication in the docs how to do that. I came across an answer on StackOverflow that suggests using urlMiddleware in place of fetchQuery. If that's really the intended approach, I think the docs could be clearer in indicating that.

@AnotherHermit
Copy link
Collaborator

This project is not just middleware, it replaces the standard Network implementation (i.e. it defines its own fetchQuery) with an addition of middleware. So the answer you linked to in stackoverflow is really all the code you need to create the network part of the environment, so there is no need to define your own fetchQuery.

@nirvdrum
Copy link
Contributor Author

Okay. That's helpful, but I still think having a short transition section in the docs would be helpful. Even reading that StackOverflow answer, it's not clear to me how variables and query text ought to be handled. urlMiddleware doesn't have options for either and the StackOverflow answer glosses over that detail.

It may be that react-relay-network-modern does something sensible under the covers, but that's not really spelled out anywhere that I can find.

@AnotherHermit
Copy link
Collaborator

RelayNetworkLayer from this project is a full implementation of a Network Layer which implies that query text and variables are all handled under the hood. Use it instead of injecting a fetchQuery into the default Network, then when using any kind of functionality from Relay (like QueryRenderer etc.) each request and response will be passed through the middleware stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants