-
Notifications
You must be signed in to change notification settings - Fork 26
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
Basic Questions #46
Comments
Hey @johannesschobel , Thank you! To answer your first question: Coloquent is indeed only a client-side library. Here is a very comprehensive list of server-side libraries that facilitate JSON:API compliant responses for all languages. Me personally I've used Crnk.io, for Java, but in my opinion it tries to do too much, as it aims to make you reduce your API to a set of data types that you can query, which didn't fit many of my use cases. To your second question: since Crnk I've moved to a different project that doesn't use JSON:API, but for the time that I've been on the JSON:API project, I've simply created my own set of DTOs that have the structure of JSON:API responses. So unfortunately no libraries that I can tip you on 🙁, but some tips on writing one! All my entities simply implement an interface that has three methods: "getJsonApiID(): string", "getJsonApiAttributes": object and "getJsonApiType(): string". Then I've written a little library (in a PHP project, unfortunately) that simply turns a (collection of) entity object(s) (and their related entities that are loaded) that are just retrieved from the database into a JsonApiResponse DTO (putting the loaded related entities into the 'included' array!). This way I can trivially turn any database query result (I use an ORM) into a JSON API compliant response, which is flexible enough for me. Unfortunately I don't own this code so I can't send stuff, but it should take you only a few hours to make that. It's basically the reverse of the transformation that Coloquent does to turn JSON:API responses back into a list of related entities. |
Hi @DavidDuwaer sorry to bother you but by any chance do you have an example or something regarding what you did on the PHP project you mention? thanks!! |
Dear @DavidDuwaer ,
i recently stumbled upon this library and it looks very clean to me. Nice work!
Please note, that i have not worked with this library (yet) so the following questions may be a bit stupid in your eyes. I only looked over the
README
file..So my questions are as follows:
From what i understood, this library is only used on the client-side (e.g., web application that communicates with the server) and not on the server-side?
That means, the package provides a fluent API to "generate" proper URLs and executes the http call, parses the results and so on..
If the library is used on the client-side, which server-side package would you suggest to be used with your own package? E.g., how can i easily generate JSON:API compliant responses on the server-side with TypeScript? I have already looked at a bunch of server libraries but couldn't come up with a nice solution..
All the best and thanks a lot for your time!
The text was updated successfully, but these errors were encountered: