graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

Codegen Observation

Open mattferrin opened this issue 7 years ago • 2 comments

I'm a bit of an outsider to Rust, but I've been interested in Yew and Juniper. I've had some experience finding different tools to generate TypeScript types through GraphQL introspection.

I really like that graphql-code-generator is using templating to empower people to add any language they wish more easily.

My thought is that it's great that a single command line tool can support so many languages and allow new languages to be added so easily. It would be great to see the Rust language added and other projects take inspiration, but I find myself leveraging Prisma as a pragmatic decision without the ability to build with or contribute to Rust as of yet, but I hope my comment helps in a small way.

mattferrin avatar Jul 09 '18 08:07 mattferrin

Thanks for the feedback! I agree that we should strive to integrate with the existing/standard GraphQL tooling whenever possible. (See for example that issue: https://github.com/tomhoule/graphql-client/issues/33).

I also think that we shouldn't renounce to all the nice things we get from Rust, like the convenience of using derives instead of a separate codegen step that has to be run before building.

We might be able to export our codegen as an npm module (compiling to wasm) so it could be imported from these other tools. This still wouldn't use their templating engine however. FWIW I really like quote as a kind of templating solution for Rust code.

It's also a lot more complicated to generate Rust because unlike Typescript structs/interfaces don't nest, I don't know how hard it would be to do the kind of codegen we do with just a templating language.

Specific ideas to integrate with other tools are very welcome :)

tomhoule avatar Jul 09 '18 10:07 tomhoule

There is news on this: I don't know if we can make this fit with the existing JS CLIs, but the derive macro was recently refactored so codegen could be used on its own. One of the things this should enable would be distributing this library as an npm package that could be used from other CLI tools.

tomhoule avatar Sep 16 '18 08:09 tomhoule