graphql_ppx
graphql_ppx copied to clipboard
OCaml support
Is there any reason why this package does not support native OCaml? I quickly perused the source code and I didn't see anything JavaScript specific.
The generated code uses Js.Json
and Js.Dict
to parse JSON with minimal runtime dependencies, as well as bs.obj
to create JavaScript objects rather than OCaml objects.
We could of course generate different code depending on configuration flags. There's a similarly named project at https://github.com/andreas/ppx_graphql that might be of interest for the native case, though.
I looked at ppx_graphql first, but it has major limitations – the lack of support for unions is a major one. I wish the two projects would merge. The OCaml ecosystem is already tiny, and the fragmentation makes it hard for newcomers like myself.
ppx_graphql
seems a bit aborted right now. I think it’d better to concentrate the work here if someone is willing to contribute it here.
@shinzui, I haven't spend much time on ppx_graphql
recently, but I did add basic union support. If you have specific needs, I'd be happy to help if you create issues.
It would be great to consolidate efforts, and I have actually spend a great deal of time looking into this, but it seems to me that the tax of being Bucklescript-compatible is quite high. In particular you're stuck on OCaml v4.02.3, but even worse, all transitive dependencies must be BS-compatible too. For example, this means no Alcotest when writing tests.
I would love to see a united Reason/OCaml ecosystem, but it appears quite hard in practice. I wonder if there are any libraries that have pulled this off successfully to learn from?
@andreas I'm not sure it's a big problem with dependencies here. Since only the output has to be BS compatible and the ppx itself is compiled to native.
Since we migrated over to distributing binaries in the npm package, I guess nothing's really preventing us from moving to the latest OCaml release as long as the output is compatible with BuckleScript as @wokalski said.