-
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
Fix #650 (@desc not working on field arguments) #738
Fix #650 (@desc not working on field arguments) #738
Conversation
Also fixes the `:name` option not working for arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on!
In theory, the only clause that should be necessary within build types is
absinthe/lib/absinthe/blueprint/schema.ex
Line 110 in ad2e4c2
defp build_types([{:desc, desc} | rest], [item | stack], buff) do |
lib/absinthe/schema/notation.ex
Outdated
|
||
[ | ||
get_desc(ref) | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, if we weren't adding the get_desc
call here, then it wouldn't have ended up on the stack at all.
lib/absinthe/schema/notation.ex
Outdated
@@ -1201,15 +1201,19 @@ defmodule Absinthe.Schema.Notation do | |||
attrs | |||
|> handle_deprecate | |||
|> Keyword.put(:identifier, identifier) | |||
|> Keyword.put(:name, to_string(identifier)) | |||
|> Keyword.put_new(:name, to_string(identifier)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
lib/absinthe/blueprint/schema.ex
Outdated
@@ -141,6 +141,11 @@ defmodule Absinthe.Blueprint.Schema do | |||
build_types(rest, [enum | stack], buff) | |||
end | |||
|
|||
defp build_types([%Schema.InputValueDefinition{} = arg, {:desc, desc} | rest], stack, buff) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's weird is that this shouldn't be necessary because the
absinthe/lib/absinthe/blueprint/schema.ex
Line 110 in ad2e4c2
defp build_types([{:desc, desc} | rest], [item | stack], buff) do |
However if I remove this clause locally, the tests no longer pass. Investigating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah of course, this is what you were saying, I see it now.
absinthe/lib/absinthe/blueprint/schema.ex
Line 149 in ad2e4c2
defp build_types([%Schema.InputValueDefinition{} = arg | rest], [field | stack], buff) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darrenclark Thanks again for taking this on, and your thoughtful remarks in the description. I do think after looking through this that I'd prefer to treat arg
as scoped so that there is only one {:desc
oriented clause within build_types
. This may be helpful for other macros as well, if I had to guess value
probably has this issue too. I don't really want to add special case look-aheads for each of those macros.
Any thoughts on if I should go as far as adding it to Or just update absinthe/lib/absinthe/schema/notation.ex Lines 1182 to 1197 in 7f7cb9e
|
@darrenclark go ahead and add it to scoped defs. |
@benwilson512 updated |
Thank you!!! |
Likewise thanks! |
@desc
not working on field arguments):name
option not working for argumentsApproach I took
Since
Absinthe.Blueprint.Schema.build_types/3
doesn't push aInputValueDefinition
onto the stack (it sets is on theFieldDefinition
), a{:desc, _}
tuple doesn't get applied to theSchema.InputValueDefinition
.I added a clause to
build_types/3
that peeks ahead of aInputValueDefinition
to consume the{:desc, _}
tupleOther thoughts
Looking back, would it make more sense to instead to:
Absinthe.Schema.Notation
create a:close
element afterSchema.InputValueDefinition
(and any{:desc, _}
for that argument), and,Schema.InputValueDefinition
on the stack inbuild_types/3
, then wait for the:close
to set it on theSchema.FieldDefinition
, andbuild_types/3
clause for{:desc, _}
handle settingdescription
on theSchema.InputValueDefinition
Thoughts?