-
Notifications
You must be signed in to change notification settings - Fork 122
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
Compose multiple Rest Links? #264
Comments
hey @sbauch -- definitely the intended way to combine multiple endpoints is within a single That's not to say it's impossible for us to enhance apollo-link-rest to support this pattern -- would you mind explaining why you want separate Apollo's built-in model includes |
I need to send different auth headers to the different endpoints, and it initially didn't seem like there was a way to send a different header per endpoint, though perhaps I could use different Some part of me feels like having multiple I'm happy to give |
@sbauch -- Another relatively easy alternative would be to provide a Depending on what headers you need to attach, the |
I think part of my challenge is that these REST APIs are really more "REST-like", and so in addition to headers, I need to also provide but, I do have a working solution with const splittableLink = new ApolloLink((operation, forward) => {
operation.setContext({
endpoint: ZENDESK_OPERATIONS.includes(operation.operationName)
? 'zendesk'
: 'airtable',
});
return forward(operation);
});
const link = splittableLink.split(
(operation) => {
return operation.getContext().endpoint === 'zendesk';
},
zendeskLink,
airtableLink,
);
const client = new ApolloClient({
link,
cache: new InMemoryCache(),
}); |
@sbauch yeah -- given your constraints, the |
The frustrating thing about this solution is that it doesn’t allow you to call zendesk and airtable in the same query (unless I missed something) |
I'm wanting to consume two 3rd party APIs from my (react native) app.
My setup looks like this, omitting things like
responseTransformer
:I then specify endpoints in the @rest directives of all of my queries:
It seems that all of the queries are routed to the RestLink that is listed first in the
ApolloLink.from
array? I'm not sure tbh, it's a bit hard to track down what's happening to the queries for the second RestLink.I recognize this is maybe not what this project is intended for, and I'm definitely using the
endpoints
map in a way different than intended, but should something like this be possible with apollo client?The text was updated successfully, but these errors were encountered: