Skip to content
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

Add an option to provide module for the custom scalar definitions #354

Merged
merged 4 commits into from
Feb 13, 2021

Conversation

miterst
Copy link
Contributor

@miterst miterst commented Nov 30, 2020

Description

Currently, the definitions for the custom scalars have to specified in the parent (super ) module.
For example if you have a custom DateTime scalar it generates for you type DateTime = super::DateTime;

This PR adds the option custom_scalars_module which can be used to specify the path to the module that contains the definitions for the custom scalars that are necessary for the generated query.

For the above example, setting this option to crate::custom_scalars the generated code for the DateTime scalar will be
type DateTime = crate::custom_scalars::DateTime;

How it can be used

  • From the graphql-client
     graphql-client generate query.graphql --schema-path schema.graphql --custom-scalars-module='crate::custom_scalars'
  • deriving
     #[derive(GraphQLQuery)]
     #[graphql(
         schema_path = "schema.graphql",
         query_path = "query.graphql",
         custom_scalars_module = "crate::custom_scalars",
     )]
     pub struct MyQuery;

Closes #245

@miterst miterst marked this pull request as draft November 30, 2020 10:22
@tomhoule
Copy link
Member

Amazing, thanks for the PR! I don't have time to review right away, but I will come back to it very soon. Is it already ready for feedback?

@miterst miterst marked this pull request as ready for review November 30, 2020 10:44
@miterst
Copy link
Contributor Author

miterst commented Nov 30, 2020

Amazing, thanks for the PR! I don't have time to review right away, but I will come back to it very soon. Is it already ready for feedback?

I saw that some tests on the nightly build had failed(worked on my machine 😅 ).
I will try to fix them later.

Anyway it's ready for feedback.

@tomhoule
Copy link
Member

tomhoule commented Dec 3, 2020

I just did a first read-through over my lunch break, and it looks great. Next steps for me is looking into the CI failures in case you need help, and confirm manually that it works, then I think we can merge :) A release is also long overdue, so I'll try to find time for that after this PR is merged.

@miterst
Copy link
Contributor Author

miterst commented Dec 11, 2020

I just did a first read-through over my lunch break, and it looks great. Next steps for me is looking into the CI failures in case you need help, and confirm manually that it works, then I think we can merge :) A release is also long overdue, so I'll try to find time for that after this PR is merged.

The tests were failing because there was a compiler bug in Rust unstable and was affecting one of the WASM examples.
With the new Rust unstable it seems to be compiling without any problems.

@tomhoule
Copy link
Member

I've delayed manual testing for this too long, I'm going to take some time now to do it.

@tomhoule tomhoule merged commit 3405863 into graphql-rust:master Feb 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Force specifying a module for custom scalars
2 participants