You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Elixir version (elixir -v): elixir 1.12.3 with erlang/otp 24
Absinthe version (mix deps | grep absinthe): absinthe 1.6.6
Client Framework and version (Relay, Apollo, etc): I am just using Absinthe.run!/3
Expected behavior
field/4 aliasing with :name should work in an input_object/3.
Actual behavior
field/4 aliasing with :name doesn't work in an input_object/3.
Relevant Schema/Middleware Code
Please inspect the following demo project and run mix test: https://github.com/srfsh/foo_bar
I think it only happens with fields that have more than one underscore. To demonstrate that, I added shop_id and awesome_owner_id. You can remove show_id related code and try with only awesome_owner_id (don't forget to run tests with and without awesome_ prefix if you do so).
I'll put the result of the test here (please look at the messages):
With shop_id
$ mix test
1) test Query book() (SchemaTest)
test/schema_test.exs:8
match (=) failed
code: assert %{data: %{"book" => data}} = run!(" query {\n book(id: \"some uuid\") {\n id\n title\n shop\n awesomeOwner\n }\n }\n", Schema)
left: %{data: %{"book" => data}}
right: %{errors: [%{locations: [%{column: 7, line: 6}], message: "Cannot query field \"awesomeOwner\" on type \"Book\". Did you mean \"awesomeOwner\"?"}]}
stacktrace:
test/schema_test.exs:9: (test)
2) test Mutation createBook() (SchemaTest)
test/schema_test.exs:26
match (=) failed
code: assert %{data: %{"createBook" => data}} = run!(" mutation {\n createBook(book: {\n title: \"title of the book\"\n shop: \"some other uuid\"\n awesomeOwner: \"some uuid\"\n }) {\n id\n title\n shop\n awesomeOwner\n }\n }\n", Schema)
left: %{data: %{"createBook" => data}}
right: %{
errors: [%{locations: [%{column: 7, line: 10}], message: "Cannot query field \"awesomeOwner\" on type \"Book\". Did you mean \"awesomeOwner\"?"}, %{locations: [%{column: 16, line: 2}], message: "Argument \"book\" has invalid value {title: \"title of the book\", shop: \"some other uuid\", awesomeOwner: \"some uuid\"}.\nIn field \"awesomeOwner\": Expected type \"ID!\", found null.\nIn field \"awesomeOwner\":
Unknown field. Did you mean \"awesomeOwner\"?"}, %{locations: [%{column: 7, line: 3}], message: "Duplicate input field name."}, %{locations: [%{column: 7, line: 5}], message: "Duplicate input field name."}]
}
stacktrace:
test/schema_test.exs:27: (test)
..
Finished in 0.1 seconds (0.00s async, 0.1s sync)
1 doctest, 3 tests, 2 failures
Randomized with seed 774466
Without shop_id
$ mix test
1) test Query book() (SchemaTest)
test/schema_test.exs:8
match (=) failed
code: assert %{data: %{"book" => data}} = run!(" query {\n book(id: \"some uuid\") {\n id\n title\n awesomeOwner\n }\n }\n", Schema)
left: %{data: %{"book" => data}}
right: %{errors: [%{locations: [%{column: 7, line: 5}], message: "Cannot query field \"awesomeOwner\" on type \"Book\". Did you mean \"awesomeOwner\"?"}]}
stacktrace:
test/schema_test.exs:9: (test)
2) test Mutation createBook() (SchemaTest)
test/schema_test.exs:24
match (=) failed
code: assert %{data: %{"createBook" => data}} = run!(" mutation {\n createBook(book: {\n title: \"title of the book\"\n awesomeOwner: \"some uuid\"\n }) {\n id\n title\n awesomeOwner\n }\n }\n", Schema)
left: %{data: %{"createBook" => data}}
right: %{
errors: [%{locations: [%{column: 7, line: 8}], message: "Cannot query field \"awesomeOwner\" on type \"Book\". Did you mean \"awesomeOwner\"?"}, %{locations: [%{column: 16, line: 2}], message: "Argument \"book\" has invalid value {title: \"title of the book\", awesomeOwner: \"some uuid\"}.\nIn field \"awesomeOwner\": Expected type \"ID!\", found null.\nIn field \"awesomeOwner\": Unknown field. Did you mean
\"awesomeOwner\"?"}, %{locations: [%{column: 7, line: 3}], message: "Duplicate input field name."}, %{locations: [%{column: 7, line: 4}], message: "Duplicate input field name."}]
}
stacktrace:
test/schema_test.exs:25: (test)
..
Finished in 0.09 seconds (0.00s async, 0.09s sync)
1 doctest, 3 tests, 2 failures
Randomized with seed 711744
The text was updated successfully, but these errors were encountered:
Can you try using snake case instead of camel case in the name? E.g.: field :awesome_owner_id, non_null(:id), name: "awesome_owner"
It works. That's strange; I thought :name option was used for defining the ouput/display type (camelCase), not the one you pass to field/4 as the first parameter (snake_case). What is the intended usage of :name? The former or the latter?
I just ran into this today. I have something where I'd like to define a field on an input object but control the name of the field so that :user_id_in can be defined in the schema as userId_in. But it doesn't seem to work in the way I think it should.
Environment
Absinthe.run!/3
Expected behavior
field/4
aliasing with:name
should work in aninput_object/3
.Actual behavior
field/4
aliasing with:name
doesn't work in aninput_object/3
.Relevant Schema/Middleware Code
Please inspect the following demo project and run
mix test
: https://github.com/srfsh/foo_barI think it only happens with fields that have more than one underscore. To demonstrate that, I added
shop_id
andawesome_owner_id
. You can removeshow_id
related code and try with onlyawesome_owner_id
(don't forget to run tests with and withoutawesome_
prefix if you do so).I'll put the result of the test here (please look at the messages):
With
shop_id
Without
shop_id
The text was updated successfully, but these errors were encountered: