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

Executing a query should error when aliasing a field with the same name as a field of incompatible type #1153

Open
caitlinhalla opened this issue Feb 15, 2022 · 0 comments
Labels

Comments

@caitlinhalla
Copy link

Environment

  • Elixir version: 1.12.1-otp-24
  • Absinthe version: pinned at sha: "738f97b96d77f793a99098aa9008683d9b6ab991" in our service, however, also validated that this occurs in Absinthe 1.7.0

Expected behavior

I would expect the execution of the following query containing a field aliased with the same name as a field of incompatible type to error:
query { thing(id: "foo") { otherThing: name otherThing { name } } }

Instead, the aliased field is simply omitted from the response as follows:
{:ok, %{data: %{"thing" => %{"otherThing" => "Foo"}}}}

Relevant thread in #absinthe-graphql: https://elixir-lang.slack.com/archives/C0PR49P4P/p1644946451423759 that points to the spec for this case.

Relevant Schema/Middleware Code

I traced this issue to Absinthe.Resolution.Projector.project/5, which is where field selections are collected by using either the alias or field name as the key in the accumulator here: https://github.com/absinthe-graphql/absinthe/blob/master/lib/absinthe/resolution/projector.ex#L52.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants