vtex-apps / store-graphql

GraphQL schema and resolvers for the VTEX Commerce Stores API
78 stars 45 forks source link

use get instead of post when requesting the simulation API #660

Closed hiagolcm closed 1 week ago

hiagolcm commented 9 months ago

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

vtex-io-ci-cd[bot] commented 9 months ago

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.

vtex-io-docs-bot[bot] commented 9 months ago

Beep boop :robot:

I noticed you didn't make any changes at the docs/ folder

In order to keep track, I'll create an issue if you decide now is not a good time

hiagolcm commented 9 months ago

@garrucho Do you think the URL maximum length could be exceeded when the simulation payload has too many items? I think if it was the case we would already have problems since the catalog already uses the GET method, but I would like to have your perception about it

We could add a POST request as fallback for example. what do you think?

garrucho commented 9 months ago

@garrucho Do you think the URL maximum length could be exceeded when the simulation payload has too many items? I think if it was the case we would already have problems since the catalog already uses the GET method, but I would like to have your perception about it

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 items array has a single object is welcomed. And/or, you can also consider checking the length of the generated URL to fallback it as POST if higher than a number (to be defined; the limit also includes the URL host).