oasis-open / odata-rapid

Rapid - Specification, tools and libraries to support the development and adoption of simple REST-based APIs.
https://rapid.rocks
Apache License 2.0
17 stars 8 forks source link

[Proposal] Add ability to issue GraphQL queries that will transform to Rapid #7

Open wtrocki opened 4 years ago

wtrocki commented 4 years ago

I went through the documentation and got some ideas. The main chance to get more coverage and love of the developers is to simplify some of the client-side work.

My thoughts

This cannot be done in spec. There should be some implementation like Apache Olingo that will implement or address those concerns (unless spec will address this by using

Idea

As we have GraphQL based DSL maybe we could also explore adding a layer of graphql queries. Wrapping OData (and OpenAPI in general) is a very common use case with dozens of libraries for the client.

https://github.com/microsoftgraph/graphql-demo/

Even Microsoft tried something like this at some point. With additional translation layer to URLs we will get a number of benefits:

GEricson commented 4 years ago

Maybe not now, but next logical step to specifying a model in RSDL is to making queries in RSDL and expressing payloads in RSDL. This feels like just another negotiated representation choice.

wtrocki commented 4 years ago

This has implications. What we have now is Dev time model that is not being used at runtime. If we decide that this would be wort considering it will be easier to keep RSDL at runtime - at least for reference implementation

wtrocki commented 4 years ago

I think we can:

  1. Use GraphQL-Mesh - Developers can get their ODataAPI I have been working closely with Urigo so if there will be need for any changes we can commit them directly to the repository. Developers can use this as proxy if they want.

  2. Work on the abstraction for filtering (the biggest change is to define what filters are available. For that we need to start with RDSL ability to define querability - similar to the directives we proposed for GraphQL based solution

  3. If developers do not want to use this as a proxy we will provide GraphQLQuery to URL translation client that can be used as a simple client here (however we going to lose cache and graphql compatible responses. What I can think of is if we actually do it for some specific graphql client we can format Odata Responses to look like they came from the GraphQL server (that will be matter of removing some of the metadata and adding operation header. This library will be best to be done as separate repository.

wtrocki commented 4 years ago

CC @mikepizzo @ralfhandl

mikepizzo commented 2 years ago

Note that, for (1), we have added a tutorial (#301) for using GraphQL with RAPID via GraphQL Mesh. The current GraphQL Mesh ODataHandler passes through things like $filter and $top, but that may not be the way that we want to pass through such query refinements, in which case we would want to propose modifying this to address (2).

That leaves (3), defining a tool for converting GraphQL requests to OData URLs (and responses to GraphQL)