Is useQuery abstraction possible? #136
Unanswered
NoeReverse
asked this question in
Questions
Replies: 1 comment
-
That approach should work. You can even use your own wrapper within defineQuery |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Due to the nature of our backend, we make hundreds of queries to retrieve data. We use our own format, very similar to JSON-RPC protocol. All requests are sent by POST method, the request body is standardized.
method
- string with the name of the called method on the backend.data
- an array or object with parameters that are passed to the method (in JSON-RPC it is the params key). For example, offset and limit for pagination are passed inside data.By parameters of the request, we determine the URL to which it will be sent, as well as standardize the creation of query keys and add the auth data. So I would like to consult on how to properly abstract over the useQuery function, so that a developer would only need to call a special function with standardized parameters and get the result without having to describe query and key independently.
Is this possible and how consistent is it with the principles of the Pinia Colada? How would you implement it, if so?
I think we could do something like that, but I'm not sure that's the correct approach, or we somehow have to apply the defineQuery here.
Beta Was this translation helpful? Give feedback.
All reactions