Reason-graphql-fullstack – simple fullstack (native + JS) example using GraphQL + sharing types



Ever since finding out about Reason and BuckleScript, something that has always been in the back of my head was one question: How do I write a fullstack Reason application in which my OCaml types are shared between a backend that is compiled to native and a frontend compiled to JavaScript?

Coming from the Clojure world where we can share a lot of code between JVM Clojure and ClojureScript, this has been, for me, the biggest barrier to writing more apps in Reason.

Just last week, though, I started playing around with GraphQL and finding out about all the niceties around ocaml-graphql-server and graphql_ppx, and I decided to try and put together something simple over the weekend.

reason-graphql-fullstack, which I published to GitHub, is the culmination of my efforts. Besides achieving what I initially intended, it includes much more than I thought possible, e.g. all the neat features that ocaml-graphql-server provides, such as a strongly typed GraphQL schema definition and co-located GraphQL queries with my ReasonReact components through graphql_ppx.


Following up on this, I gave a talk at Small FP Conf 2018 last week that talks about how I got to this approach, and they just published the video.

Here’s the Youtube link: