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

feat(juniper_codegen): add conversions for enum variants to strings #540

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

garbados
Copy link

Hi!

This PR expands the GraphQLEnum derive macro to provide conversions from enum variants into strings. Currently, the macro only provides conversions for InputValue, but in my usage it became necessary to map enum variants into Value::scalar::<String> types so that they can be used in GraphQL responses, specifically as the second parameter of FieldError::new. Mapping enum variants to strings directly, rather than a Juniper type, is an artifact of my not knowing much.

I'm new to Rust and even newer to Juniper, so this PR is intended for review and discussion, and I am happy to incorporate any feedback.

@LegNeato
Copy link
Member

Hello! Thank you for the PR and welcome! 🍻

First, I think there are some legit errors on CI related to this PR:

https://dev.azure.com/graphql-rust/GraphQL%20Rust/_build/results?buildId=684&view=logs&j=150c9611-1cfc-59c0-d4e8-92df330f7380&t=10bef84d-ad0f-569a-c6cb-c54604a7beb6&l=458

(sorry, our CI is a bit messy right now...I am working to clean it up).

Second, I think this sounds like a great change but need to think about it a bit more. I haven't really touched enums too much 😄

@garbados
Copy link
Author

First, I think there are some legit errors on CI related to this PR:

I see those errors but none are related to the code I added, so I don't know how to make sense of them . Can you provide any guidance?

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.

None yet

2 participants