My first week of ReasonML
Last week was the first week of actually using ReasonML to build an application instead of looking at Reason theoretically. If you want to know what I’m building you’ll have to keep an eye on the Open Social blog but below I’ll take you through my experience.
Reason vs ReasonML vs BuckleScript vs ReScript
There is a thriving community for both ReasonML and ReScript. The Reason Discord has focused itself around native development (although there are still some lesser active ReScript channels). The ReScript team has set-up a new Discourse forum where they’ve included an FAQ about the changes.
ReScript with NodeJS vs Native Reason
With some help from the Reason discord I’ve decided to build the GraphQL server with Reason Native. The biggest hurdle was making sure that Reason could be built and run on Platform.sh which is one of the hosting providers of Open Social. Thanks to the people on Discord we were able to figure out how to do this.
To build the GraphQL server itself I’ve been using Morph which wraps ocaml-graphql-server and a webserver together in an easy to use package. It’s been quite a ride to learn how to use esy and figure out how all the types work. However, over the course of the week I’ve been slowly figuring out how to deliberately trigger type errors to see what types I’m working with. Knowing what to do with those types is also coming more easily every day and to my surprise I’m even learning to read OCaml by regularly converting small snippets using Reason Try.
I’ll continue working on the GraphQL server. I’ve been able to create my first connections to the database and my first parts of the GraphQL schema. Along the way I’ve been able to add tests using Rely. It feels like a lot of the initial exploring is complete and I can now start duplicating and modifying my initial snippets to add more models and endpoints.
Implementing GraphQL Subscriptions will be an upcoming adventure and will require playing with some more experimental Morph code. Beyond that I’ll be moving on to some work on consuming GraphQL from the same Reason Native application.
In a few more weeks still I hope to be able to start playing more concretely with the improvements that have been made to the ReScript language and start using React with the GraphQL client tools to consume data from our newly built Reason Native GraphQL server. Stay tuned!