-
Notifications
You must be signed in to change notification settings - Fork 0
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
Alternative #81
Comments
Hey @texttechne thanks for the input. I had a quick look through odata2ts, not enough to fully understand it, but I can see some key differences in the focus between projects. I am sure to miss a lot of things, so please fill in any features which are available in odata2ts and not in magic-odata, or features which are available in both odata2ts
magic-odata
As you said, odata is a massive set of features, and it is not only clients that implement a subset of functionality, but also servers. My guess is that the flavor of the client will depend on which OData server was the primary influence for the project, and that odata2ts and magic-odata have been influenced by different server implementations |
@texttechne if you would like, there is an odata $metadata file buried in magic-odata that handles a lot of edge cases. Feel free to grab it if you would find it useful for TDD |
Hey @ShaneGH, Ok, here is my try of a comparison. Feature comparisonmagic-odata
Currently, I'm working on My main problem with some of the advanced querying features ($root, $this, ...) is that I'm lacking a test server which supports these features. The SAP stuff is quite limited in that respect and the official implementations I know (TripPin, OData, Northwind) also don't support such stuff. And without any way to at least test this functionality manually I won't implement it. And some of those features like parameter aliases are actually not needed => see querying philosophy odata2ts
For completeness' sake, some stuff you've mentioned missing has been implemented:
Querying PhilosophyThere's one main difference: both implementations approach querying differently. odata2ts is heavily inspired by Java tools like QueryDsl or jOOQ which generate "query-objects" to provide filter functionality. odata2tsClient.navToPeople().query((builder, qPerson) =>
builder
.filter(
// lastName will only offer string based operations and requires string as argument
qPerson.lastName.contains("x"),
// age as number property only accepts numbers
qPerson.age.gt(18)
)
.expanding("trips", (tripsBuilder, qTrip) =>
tripsBuilder
.select("budget")
.orderBy(qTrip.budget.desc())
.top(1)
)
) magic-odata follows a more generic approach as far as I can judge: odataClient.People
// the person object is generated right?
.withQuery((person, { $filter: { containsString, eq } }, params) =>
containsString(person.LastName, "x")
// is the value comparison for numeric prop a string or a number? i guess string because it's generic?!
.and(eq(person.Age, "18"))
)
// sorry, here I'm lost: how do I specify the expanding now? So, magic-odata relies on the knowledge of the user when building queries: Extensibilityodata2ts keeps two aspects open for extension:
Two HTTP client implementations are provided (Axios, JQuery) but it should be easy enough to implement any other technology according to the API. This approach was chosen since some advanced features should be handled by the HTTP client and not backed in into odata2ts:
The other main concern is data types. When confronted with something like |
@texttechne emailed you |
@texttechne all of this makes sense, cheers. Regarding your issue with test servers and $root and $this, my philosophy on it has been:
Regarding extensibility, magic-odata takes a much more low level approach. Rather than come up with a list of things that could be extended, magic-odata goes with a middleware like approach with interceptors available at all levels of http request generation This allows things like headers, caching, auth and even http client types to be completely customizable either globally or per request Specifically regarding
Other parts of the spec like, http status codes, also introduce concepts which are not possible to model in typescript (they are not known at compile time), and so are also considered out of scope (for now, although with a long enough time frame, this will be addressed) Regarding the code snippet of magic-data (
Regarding data types, care has been taken to fully support all data types from a query point of view Regarding some misc points not covered above.
|
Hi @ShaneGH,
You're right there and you do make some really excellent points. I'll switch my philosophy there => convinced! 😁 And it should be clear by now, that both libs implement nearly the same feature set. Regarding the data types: this has been a major concern for Taking this one step further and this is my holy grail for the project (#107), when $selecting or $expanding the reponse structure is shaped. Since this information is readily available in the query builder it should get reflected in the typing of the response... |
Hi,
I'm really unsure if I should open this ticket, but here I go.
I'm the author of odata2ts. And it actually does what
magic-odata
does. Have you considered this as alternative?Don't get me wrong: It's always cool to have alternatives and there also exist quite different reasons to have them. But since I know how long the road is to generate a full featured OData client (nearly impossible 😉)...
Anyways, I hope I don't step on your toes by writing this.
But then again, I'm curious and if you have considered it as alternative and wanted to have a different tool, then I would be highly interested in those reasons.
The text was updated successfully, but these errors were encountered: