You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, congrats on this awesome lib, it is really been handy for our projects and saves a lot of time.
I have just a small question, been looking at open issues but can't really find one about this particular topic.
Most of the times, when we use a queryFn or mutationFn, we do the request and return the data directly, but in some cases, we want to do some extra logic after the response is returned. For example, on requesting lists, we want to access the headers and return a custom object, such as
Also on mutations, after we create an entity, we want to create the images after the post request is successfull, so we add this logic on the same mutationFn that creates the entity.
The bottom line is, can we add extra "code" or logic when we call the getUserOptions method or postUserMutation generated by the hey-api codegen, or this is not really correct implementation and we should really just separate the logic into separate functions and methods and call them accordingly at each step?
Thank you for the attention
I'm always available for new info or questions
The text was updated successfully, but these errors were encountered:
Sure! I just think it would be a nice to have, since i think this is a common use case that other developers may eventually need, to add custom logic before the return, but i'm also not sure how to do this, maybe add a callback or something, but yeah, just giving some feedback. Thanks for the reply, will be checking in for updates!
Hello, congrats on this awesome lib, it is really been handy for our projects and saves a lot of time.
I have just a small question, been looking at open issues but can't really find one about this particular topic.
Most of the times, when we use a queryFn or mutationFn, we do the request and return the data directly, but in some cases, we want to do some extra logic after the response is returned. For example, on requesting lists, we want to access the headers and return a custom object, such as
const getUsersQuery = (params?: BaseListParams) => ({ queryKey: ['users', params], queryFn: async () => { try { const { data, headers } = await api.getUsersApi(params); return { data, totalCount: headers.totalCount, nextPage: headers.nextPage }; } catch (err: unknown) { throw err; } } });
Also on mutations, after we create an entity, we want to create the images after the post request is successfull, so we add this logic on the same mutationFn that creates the entity.
The bottom line is, can we add extra "code" or logic when we call the getUserOptions method or postUserMutation generated by the hey-api codegen, or this is not really correct implementation and we should really just separate the logic into separate functions and methods and call them accordingly at each step?
Thank you for the attention
I'm always available for new info or questions
The text was updated successfully, but these errors were encountered: