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

Support dynamic Enum value #1023

Merged
merged 3 commits into from
Jan 14, 2021

Conversation

binaryseed
Copy link
Contributor

This PR adds support for dynamic Enum values in macro based schemas using unqoute like in #1005

@binaryseed binaryseed changed the title Support dynamic Enum values Support dynamic Enum value Jan 3, 2021
@@ -145,7 +145,7 @@ defmodule Absinthe.Blueprint.Schema do
end

defp build_types([{:values, values} | rest], [enum | stack], buff) do
enum = Map.update!(enum, :values, &(values ++ &1))
enum = Map.update!(enum, :values, &(List.wrap(values) ++ &1))
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the need to wrap these in a list?

Copy link
Contributor Author

@binaryseed binaryseed Jan 6, 2021

Choose a reason for hiding this comment

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

Ahh, yes this is the sneaky bit. Now that values are wrap_in_unquote'd it can now be a list of atoms or AST for a function call - so I just wrap everything in a list here so that it can continue to collect in a list.

Then in the end after this all is injected into __absinthe_blueprint__ it'll be some form of nested list, and I can call List.flatten(type_def.values) to get the final resulting list....

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.

2 participants