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

Using coloquent with RTK query #107

Open
spartanrein opened this issue Jun 1, 2023 · 3 comments
Open

Using coloquent with RTK query #107

spartanrein opened this issue Jun 1, 2023 · 3 comments

Comments

@spartanrein
Copy link

Hi everyone,
I would like to use coloquent with redux toolkit query, but haven't been able to find any references or discussions for doing so.
If it's not possible to use coloquent within the query logic, could we possibly build the models from the response of the jsonapi rtk query?

Cheers all

@spartanrein
Copy link
Author

I'd like to follow up on my question above, please

@ZehaIrawan
Copy link

I have the same issue and can't find any resources, any news?

@DavidDuwaer
Copy link
Owner

DavidDuwaer commented Aug 10, 2023

I haven't heard of earlier attempts of people trying this. No experience with RTK myself, but have you made an attempt to wrap a Coloquent query inside RTK queries? What kind of trouble are you running into?

If you want to instead wrap RTK queries in Coloquent queries somehow, a path you can try is making a custom implementation of Coloquent's HttpClient interface. A Coloquent HttpClient takes Coloquent queries and returns anonymous object/array data that Coloquent can assemble into classfull objects and interlink. You can then override Coloquent's static Model.httpClient property to make Coloquent use your HttpClient implementation. E.g.

import { Model, HttpClient } from 'coloquent'

class MyCustomHttpClient implements HttpClient { ... }

Model.httpClient = new MyCustomHttpClient(...)

For more details on how to implement such a client beyond what the types will tell you you have to refer to the implementation of the default AxiosHttpClient, and its usage in Model.ts. I'm sorry there is not more documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants