graphql_ppx icon indicating copy to clipboard operation
graphql_ppx copied to clipboard

OCaml support

Open shinzui opened this issue 6 years ago • 6 comments

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.

shinzui avatar Feb 26 '18 14:02 shinzui

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.

mhallin avatar Feb 26 '18 15:02 mhallin

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.

shinzui avatar Feb 26 '18 16:02 shinzui

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.

wokalski avatar Feb 26 '18 16:02 wokalski

@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 avatar Feb 26 '18 18:02 andreas

@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.

wokalski avatar Feb 26 '18 20:02 wokalski

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.

mhallin avatar Feb 26 '18 20:02 mhallin