Skip to content
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

Request POST as GET: api limits, filter (and perhaps undocumented SEARCH http method) #1823

Open
jokeronice opened this issue Jan 14, 2025 · 1 comment
Labels
workaround A workaround has been provided

Comments

@jokeronice
Copy link

Hello, everyone,

As is the case with many APIs, we now have one where a GET request functions as a "search endpoint." This endpoint supports numerous parameters, potentially enough to exceed the 2048-character URL length limit. While I agree that it might be better to split this functionality into different endpoints or impose stricter limits on the parameters, the decision has been made to take a simpler approach by using a POST request instead. This allows all the parameters to be included in the body of the POST request.

However, this solution disrupts Orval's code generation, as POST requests are typically intended for mutations. Is there a way to "override" the method for this GET endpoint and use a POST request instead?

Thank you for your input!

@melloware melloware added the enhancement New feature or request label Jan 14, 2025
@melloware
Copy link
Collaborator

This exists already...

override: {
        mutator: defaultMutator,
        operations: {
          project_aggregation_query: {
            query: {
              // This is a POST request, since it requires a request body, but is actually a query, not a mutation.
              // This forces Orval to generate a query instead of a mutation hook.
              useQuery: true,
            },
          },
        },
      },

if you use useQuery it will generate a query instead of mutation.

@melloware melloware added workaround A workaround has been provided and removed enhancement New feature or request labels Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workaround A workaround has been provided
Projects
None yet
Development

No branches or pull requests

2 participants