-
Notifications
You must be signed in to change notification settings - Fork 529
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
Providing function to descriptions no longer works #935
Comments
This can be accomplished in 1.5 using In your case, you can set the description: {:description, dynamic_description()} Documented here: https://hexdocs.pm/absinthe/Absinthe.Schema.html#c:hydrate/2 |
Duplicate of #946 |
That works, thanks. Still experimenting with the "best" way to do this, but I'm currently doing something like this (for someone who stumbles onto this): # AppWeb.Schema
def hydrate(
%Absinthe.Blueprint.Schema.FieldDefinition{identifier: field_name},
[%Absinthe.Blueprint.Schema.ObjectTypeDefinition{identifier: parent_object} | _]
),
do:
{:description,
__MODULE__.Descriptions.description("field:#{parent_object}.#{field_name}")}
def hydrate(%Absinthe.Blueprint.Schema.ObjectTypeDefinition{identifier: object}, _),
do: {:description, __MODULE__.Descriptions.description("type:#{object}")}
def hydrate(_node, _ancestors), do: [] # AppWeb.Schema.Descriptions
def description(identifier) when is_binary(identifier) do
case identifier do
identifier
when identifier in [
"field:foo.bar",
"field:create_foo_input.bar",
"field:update_foo_input.bar"
] ->
"The quick brown fox"
_unsupported_description ->
nil
end
end |
Environment
Elixir 1.9.1
1.5.1
n/a
Expected behavior
Previously (eg.
1.4.16
), I could pass a function to a field's description. We do this since many fields share the same description, and it keeps things dry (eg. objects and input objects often have the same description). It also cuts down on the schema noise.Actual behavior
I'm not a macro wizard, but it seems
1.5
changed the way the macro works for descriptions (and maybe others?). The String trim logic is now attempting to trim a quoted function; which throws an error.Maybe related to #928 ?
Relevant Schema/Middleware Code
n/a
The text was updated successfully, but these errors were encountered: