juniper-from-schema
juniper-from-schema copied to clipboard
Support reading schema from multiple files
GraphQL schema files get very big very quickly, so I'd like to be able to split mine into multiple files. It'd be nice if the graphql_schema_from_file
macro could take in multiple files (or even ideally, a glob pattern), then just stitch them together before generating the Rust types. I know as a workaround I can just do something like cat schema/*.graphql > schema.graphql
which is what I'm doing now, but it'd be nice to not have to do that.
If this sounds reasonable I'm happy to work on an implementation.
Yeah that sounds like a useful feature. I have indeed seen +1000 line schema files.
I'm actually thinking about removing the procedural macros and moving entirely to doing things in build.rs
as its easier to extend and document. All the work is done actually. The code is here https://github.com/davidpdrsn/juniper-from-schema/tree/master/juniper-from-schema-build and the tests are here https://github.com/davidpdrsn/juniper-from-schema/tree/master/juniper-from-schema-build-tests.
So yes you're very welcome to add something there. Might just be as simple as reading a list of files, concatenating the contents, and compiling it as a schema literal.
@davidpdrsn Sounds good, I just started on an implementation. Do you have a preference on whether or not to pull in the https://docs.rs/glob/0.3.0/glob/ crate to support glob paths? I think it would be nice to be able to do something like schema/*.graphql
, but not sure if you want to keep the dependency tree as minimal as possible. We could also support taking in directory or file paths, so the user could just pass schema/
and it would automatically read all files in there. I think the glob pattern would be slightly more familiar/useful but don't feel too strongly about it.
Pulling in glob is fine. I also prefer glob patterns like schema/*.graphql
over just a directory 👍
@davidpdrsn Any news on this?
@acelot Nope. I haven't had much time to work on juniper-from-schema for some time. https://github.com/davidpdrsn/juniper-from-schema/pull/138 does appear to fix the issue but I haven't reviewed it. If you really want this feature I suppose your best bet is to use that through a git dependency.