-
Notifications
You must be signed in to change notification settings - Fork 47
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
batchUrl property of URL middleware is not passed req #36
Comments
So if you want to create more complex logic, do not use |
I agree with that but I am not sure we are talkin gabout the same thing.
and thus would expect this code to work:
but it seems that batchUrl does not accept a function. |
export default function urlMiddleware(opts = {}) {
const urlOrThunk = opts.url || '/graphql';
const batchUrlOrThunk = opts.batchUrl || '/graphql/batch';
const fetchOpts = opts.opts;
return next => req => {
if (fetchOpts) {
const { headers, ...otherOpts } = fetchOpts;
Object.assign(req, otherOpts);
if (headers) {
Object.assign(req.headers, headers);
}
}
let url;
if (req.relayReqType === 'batch-query') {
url = batchUrlOrThunk;
} else {
url = urlOrThunk;
}
req.url = isFunction(url) ? url(req) : url;
return next(req);
};
} See carefully that So it should work as you expected. |
Ok got it, my error should came from another part then. I am closing this now as the behavior is the one expected. |
Hello,
I wonder why url property is wrapped with req (https://github.com/nodkz/react-relay-network-layer/blob/master/src/middleware/url.js#L26) allowing for data being passed by another middleware through req but batchUrl is not.
My use case is that I am dynamically retrieving the api url with a middleware, and I would like both url and batchUrl to use the api url from req.
The text was updated successfully, but these errors were encountered: