-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI codegen ergonomics #134
Comments
@h-michael tagging you since you implemented the CLI codegen - in case you want to discuss this. |
I agree with this idea. |
There is one library with a similar problem (although it's used as a build script): prost. Relevant doc page (in particular the |
One other solution we could explore is giving options like |
Even if it is an annotation, I do not think it is a good thing to describe what is not in the specification. For example, how about this? graphql-client-cli generate --schema-path=./schema.json --deprecations=warn 'src/**/*.graphql' \
--common-additional-derives='Debug,Clone' \
--additional-derives='FooTrait:TargetStruct1,TargetStruct2' The format of the option needs to be discussed, but in essence it separates the options of deriving in common and deriving only for a specific struct. However, as I think that it is complicated as cli, I think that it may be possible to provide a config of toml format that can handle the same format. |
I agree with the config, and that we should have both config and options. There is a standard for the prisma-related graphql tooling, graphqlconfig, but I am not sure it would make more sense than using our own format. |
I'll investigate graphql-config format later. |
I think toml might be a better target - users of the library will be used to Rust and most Rust projects prefer toml (easier to read and edit, supports comments, etc.). Comparatively few people know graphqlconfig and it would be mostly custom options anyway. But I am interested to know what you think. |
I will start implementing building all queries in the same module before config. |
@tomhoule |
@h-michael 's last suggestion was implemented in 0.7.0. Closing this issue in favour of more focused ones to gather new feedback. |
At the moment the CLI generates one module for one file. The general use-case however is probably projects with more than one query, and having to issue more than one command seems a bit too complicated.
The most use similar CLI tool at the moment is apollo-cli and I think we could take a similar approach.
Invoking graphql-client-cli could look something like this:
graphql-client-cli generate --schema-path=./schema.json --deprecations=warn 'src/**/*.graphql'
, and it would generate one file per .graphql file, with one module per query.The shared code could live in one module for the whole project - we can achieve a lot more reuse with this approach than with the derive-based interface.
Let's discuss what interface we want for the CLI in this isue.
The text was updated successfully, but these errors were encountered: