-
Notifications
You must be signed in to change notification settings - Fork 45
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
use get instead of post when requesting the simulation API #660
use get instead of post when requesting the simulation API #660
Conversation
Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖 Please select which version do you want to release:
And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.
|
Beep boop 🤖 I noticed you didn't make any changes at the
In order to keep track, I'll create an issue if you decide now is not a good time
|
@garrucho Do you think the URL maximum length could be exceeded when the simulation payload has too many items? We could add a POST request as fallback for example. what do you think? |
Yes, this is a possible problem! But the simulations made by Portal/Catalog, so the Search, should always contain only a single item, reducing the chance for problems. Simulation requests with multiple items are characterized as a cart and can generate problems while retrieving conditions for a shelf/storefront, which shows individual items. A function to limit GET only to when the |
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.
I'm worried about completely changing from POST to GET. I think there are proper moments for each of them.
I'd say that GET fits only to single-item simulations that are made by the Intelligent Search. It may be risky or even not beneficial enough to change it for every simulation made by this GraphQL.
}, | ||
isCheckedIn: false, | ||
undefinedParameter: undefined, | ||
nullParameter: null, |
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.
I'd also consider creating a test for a nested null parameter to be safe about requests without regionId, which are frequent.
So, this:
{
...
shippingData: {
logisticsInfo: [{ regionId: null }],
}
}
Should generate the parameter &request.shippingData.logisticsInfo[0].regionId=
or completely omit the property (including the shippingData
part of it).
The first option is recommended if you want to keep the same semantics as the POST requests we do nowadays – if there's no specific value, it always sends the "regionId" as null.
I'm highlighting this because the nullParameter: null
was completely omitted, which is not a problem, but won't be the same and I don't know how it would be while nested.
What problem is this solving?
Jira card
The simulation API only caches the result when it's called via a GET request. Currently we call it via a POST request.
In order to the benefits from the cache, this PR changes the method from POST to GET.
How to test it?
Workspace