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

Bindings #5

Open
chriskapp opened this issue Dec 10, 2023 · 0 comments
Open

Bindings #5

chriskapp opened this issue Dec 10, 2023 · 0 comments

Comments

@chriskapp
Copy link
Member

Currently TypeAPI is used to describe REST APIs for example:

{
  "operations": {
    "getMessage": {
      "description": "Returns a hello world message",
      "method": "GET",
      "path": "/hello/world",
      "return": {
        "schema": {
          "$ref": "Hello_World"
        }
      }
    }
  },
  "definitions": {
    "Hello_World": {
      "type": "object",
      "properties": {
        "message": {
          "type": "string"
        }
      }
    }
  }
}

in this case method and path are HTTP specific (or we could call it also REST specific) bindings. We could envision a future with TypeAPI where we not only describe REST APIs but also i.e. GraphQL endpoints while still generating the same client SDKs but providing a way to exchange the underlying transport technology. To enable this we would need to abstract those bindings, the example above could be written i.e.

{
  "operations": {
    "getMessage": {
      "description": "Returns a hello world message",
      "http:method": "GET",
      "http:path": "/hello/world",
      "return": {
        "schema": {
          "$ref": "Hello_World"
        }
      }
    }
  },
  "definitions": {
    "Hello_World": {
      "type": "object",
      "properties": {
        "message": {
          "type": "string"
        }
      }
    }
  }
}

A GraphQL version could be written as:

{
  "operations": {
    "getMessage": {
      "description": "Returns a hello world message",
      "graphql:query": "{ message }",
      "return": {
        "schema": {
          "$ref": "Hello_World"
        }
      }
    }
  },
  "definitions": {
    "Hello_World": {
      "type": "object",
      "properties": {
        "message": {
          "type": "string"
        }
      }
    }
  }
}

with this idea we could also imagine many different bindings like RPC (GRPC/Thrift/JsonRPC) or maybe also MessageQueue systems or maybe also plain SQL. Through this we could achieve some sort of technology independency this means we could change the underlying technology and the SDK user still uses the same API. While this sounds pretty ambitious it could be a real game changer for clients consuming a specific backend, since then you dont need to rewrite you client in case your backend technology changes.

We still need to think about some topics i.e. like authentication. Currently a user simply provides a specific authorization type regarding REST i.e. Bearer Token or Basic Auth, for GraphQL this still might work but for other bindings like GRPC or a message queue system it would be problematic. Also would it be possible to generate a client where each operation uses a different binding, in this case the client SDK needs the fitting authorization for every binding.

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

1 participant