Hey everyone! I open-sourced some code I’ve been writing over the last several months in support of the app I’m building at work: reason-react-apollo!
It’s bindings + codegen for working with Apollo’s react-hooks library, and it takes an alternative approach to typing your GraphQL stuff than graphql_ppx. Specifically, it uses abstract types for each of your schema types that can be shared around your project instead of a specific type for each operation you define. I’ve never liked that tradeoff that graphql_ppx required, so I gradually developed an alternative approach! And, with Apollo’s release of the hooks API, everything came together really nicely.
If you’re interested in trying it out the docs site explains how to get started (it’s using GraphQL Code Generator for the codegen, so the setup mostly involves getting that configured). I’ve love to hear any feedback about how it works with your schema, the docs, or really anything! I’ve really enjoyed the experience of writing components that use queries/mutations this way and hope others will benefit, too!
) - though you introduce the possibility of an error your type system won’t catch (that is, under-fetching in a query), you’re almost 100% certain to encounter this during normal development. In most cases, as soon as you try to do something with the query - it’ll be clear the data is not there! Combined with a really easy to diagnose error message (the type accessors tell you exactly what field you were trying to access on which type), it’s incredibly easy to diagnose and fix. The chances of shipping an error of this type to a user is slim to none.