Skip to content

Allow different Scalar for GraphQLScalarValue #807

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

Merged
merged 4 commits into from
Nov 16, 2020

Conversation

jmpunkt
Copy link
Contributor

@jmpunkt jmpunkt commented Nov 15, 2020

Motivation

Currently it is not possible to use scalar values with custom scalars. The following code fails.

#[derive(juniper::GraphQLScalarValue)]
pub struct LargeId(i64);

In order to allow custom scalars, scalars values must allow to set a different scalar value. Currently the implementation only uses generics. The following snippet works with this PR. Notice that MyScalarValue is a scalar implementation including the i64 data type.

#[derive(juniper::GraphQLScalarValue)]
#[graphql(Scalar = MyScalarValue)]
pub struct LargeId(i64);

Copy link
Member

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you so much for the high quality PR with tests! 🍻

@LegNeato LegNeato merged commit cb6d89f into graphql-rust:master Nov 16, 2020
@tyranron tyranron added k::api Related to API (application interface) enhancement Improvement of existing features or bugfix labels Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix k::api Related to API (application interface)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants