-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(@cubejs-client/core): allow making HTTP POST requests to Cube.js API #1608
feat(@cubejs-client/core): allow making HTTP POST requests to Cube.js API #1608
Conversation
@hassankhan @ovr can you please guys review? Thanks. |
@@ -2,34 +2,40 @@ import fetch from 'cross-fetch'; | |||
import 'url-search-params-polyfill'; | |||
|
|||
class HttpTransport { | |||
constructor({ authorization, apiUrl, headers = {}, credentials }) { | |||
constructor({ authorization, apiUrl, method = 'GET', headers = {}, credentials }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ovr Should we also be changing the default to POST
too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should prefer the GET
method whenever possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% agree with @vasilev-alex, it's better to use GET whenever possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vasilev-alex @hassankhan Maybe it's better to set up it to undefined
by default and detects automatically.
method = method || (url.length < 2000 ? 'GET' : 'POST')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ovr yep, let's do like this. @mnifakram can you please introduce this check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes sure thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ovr @vasilev-alex I've just updated it. Please kindly check it. thanks
So, currently, I can see one limitation. It's not possible to change the const transport = new HttpTransport({
// ...
method: 'POST'
});
const cubejsApi = cubejs(CUBEJS_TOKEN, {
apiUrl: `${API_URL}/cubejs-api/v1`,
transport
});
// Can't change the `method` during runtime
// I want to send this one using `GET`
cubejsApi.load(query);
// and this one using `POST`
cubejsApi.load(query); What if we would pass the HTTP cubejsApi.load(query, { method: 'GET' });
cubejsApi.load(query, { method: 'POST' }); Or, maybe, we could allow users to override the method by passing it to the @ovr @hassankhan @mnifakram what do you think? |
@vasilev-alex I don't think that users will switch between I don't see any advantages of using |
|
Is there anything that I can help with to get this merged? I'm really in need to get this released asap. Thanks |
Any update on this? I need the ability to handle large queries as well. |
Check List
Issue Reference this PR resolves
#1558