-
Notifications
You must be signed in to change notification settings - Fork 2k
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
apollo-datasource-rest: dynamic baseurl #1181
Comments
@danilobuerger hmm interesting, I'm not sure I follow. How do you set the url dynamically? What information would it depend on? The other option is to set baseUrl to '' and then inside of get put the full url. @martijnwalraven might be interested as well. |
This is already supported by using a getter instead of setting the get baseURL() {
if (this.context.environment === 'development') {
return 'https://dev.example-api.com';
} else {
return 'https://prod.example-api.com';
}
} Would that work for your use case? Not sure how Consul SRV entries fit into this. What makes them dynamic? What are they based on? |
Hi @evans and @martijnwalraven ! Thanks for responding, I should probably have been more specific. Sorry about that. What I would like to do is something like (shortened):
Basically return a promise that would resolve to a base url based on the supplied params. In case of consul one could for example use part of the path to get the name of a microservice to resolve its srv to get its (possible load balanced, round robin, etc.) address. |
@danilobuerger Hmmm, we could make it possible to return a promise from the But why does the URL need to depend on the path, params or other call-specific information? Couldn't you just define a data source per microservice? You also probably wouldn't want to resolve for every call, that seems like quite a bit of overhead? |
True, this was just an example in brevity. You could cache the result for example or track a round robin on the returned addresses. For this specific example, you could probably get away with defining it per microservice and not having to rely on the path. I included |
@danilobuerger I experimented some and came up with 2e6073d#diff-94c74c4c5e5f1e69b942b0b56a962852R133. Not sure if it is worth the complexity, but curious what you think. |
+1 I need to poll a configuration server first before I know |
@martijnwalraven Awesome work! Line read looks good. Concept makes sense. |
@danilobuerger @godspeedelbow I incorporated the feedback and opened a PR with a discussion and some questions. Your input is appreciated! #1277 |
Fixed in #1277 |
It would be nice to specify a dynamic baseurl for a RESTDataSource to be able to use fx consul srv entries.
The text was updated successfully, but these errors were encountered: