-
Notifications
You must be signed in to change notification settings - Fork 35
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
RFC: Merge hathora.yml and server/impl.ts #165
Comments
Thanks for the RFC @CGamesPlay! After thinking about it some more these are my current thoughts: One design goal of Hathora is to achieve an effective decoupling of client and server. Let's say I'm a Swift developer specializing in adding iOS frontends for existing Hathora projects. I would want a standardized way of introspecting Hathora APIs. I don't care whether your backend is in Go or Haskell or Typescript -- I just want to read your API contract, fire up the prototype UI to play around and interact with your backend logic, and get started on my Swift client. For me, this means that the API definition shouldn't live in the I think the valid point that you bring up is that defining the API today in the I think there's a way we can get the best of both worlds. I would propose treating the HathoraConfig as the low level API representation and thinking of Hathora as tooling which (a) produces this config and (b) consumes this config. On the producing front: currently the only way to produce the
On the consuming front, the Hathora codegen engine is a consumer of The advantage of this approach is that it achieves a level of standardization across Hathora repos, regardless of backend/frontend implementation. Let me know your thoughts. |
I think that option 3 actually hits at what makes sense for every API developer: my server is the source of truth, but we need a good interchange format to make a usable API. When I'm building a REST API, this might be an OpenAPI specification (swagger). For GraphQL, you use introspection to create a schema from a running server. For gRPC, maybe it's a set of But I don't actually want to write my own OpenAPI specification, GraphQL schema file, or Once you have a "game schema" (aka I think the best model to copy is GraphQL: I write a server which presents some API. The server can generate a schema describing the API it presents (GraphQL schema). GraphQL schemas can be saved as text files on disk and parsed by every GraphQL tool; they have structured documentation embedded; and code generators can use a schema (on disk or read from a live server) to generate whatever kind of code they like. The Prototype UI of Hathora is GraphIQL. Footnotes
|
Right, but you're not arguing against (1) and (2) also being valid options, are you? I think all modes of producing |
No of course not. A |
From a private email:
I wanted to provide a proof-of-concept for a pure-typescript DSL that allows you to implement all of the features required of
hathora.yml
: usable for code generation, allows clients to be agnostic about the implementation details of the server (e.g. closed source server), usable with libraries (because it's TypeScript), privacy (via thegetUserState
function).My proof-of-concept lives in this gist. I implemented the Rock-Paper-Scissors example to demonstrate. The net result is that I output a JSON blob that matches the loaded HathoraConfig, and there's also a method which returns a compatible Impl class. Some notes points about the proof of concept:
import
lines. If you do, then the proposal is shorter by that amount.Would there be interest in adopting something like this as the preferred way of specifying the client interface in Hathora?
The text was updated successfully, but these errors were encountered: