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
If submitting a bug, please provide the following:
Environment
Elixir version (elixir -v):
elixir 1.10.2
erlang 22.3.4.1
Absinthe version (mix deps | grep absinthe):
absinthe (Hex package) (mix) locked at 1.5.2 (absinthe) 669c8487
absinthe_relay (Hex package) (mix) locked at 1.5.0 (absinthe_relay) 173cc44c
absinthe_sorting_codec 1.0.0 (Hex package) (mix) locked at 1.0.0 (absinthe_sorting_codec) e5dd8152
absinthe_sdl 1.1.0 (Hex package) (mix) locked at 1.1.0 (absinthe_sdl) 8b5f6293
absinthe_plug (Hex package) (mix) locked at 1.5.0 (absinthe_plug) 4c160f4c
absinthe_phoenix (Hex package) (mix) locked at 1.5.0 (absinthe_phoenix) bbe443e8
Client Framework and version (Relay, Apollo, etc):
None, this is failing from unit tests
Expected behavior
In the ParseIDs middleware, there is a function find_schema_root!/2. I have several inspects in place to see what is going on (which I will past below). I expect to see the following happen (This works correctly on Absinthe 1.4 but not on Absinthe 1.5)
In this result (Absinthe 1.5), we see that when the ParseIDs middleware tries to parse ids for the child field, it finds the parse_ids_root is still set as :input from the mutation, when it shouldn't. This behavior differs from Absinth 1.4.
Basically, the first ParseIDs works great parsing the IDs from the input object generated by the mutation. However, once the graph tries to parse the child field that also contains a ParseIDs middleware call, it blows up.
Mutation being run. There is a ParseIDs middleware call on both :add_tag_value_to_transaction and on :tag_values.
mutation TestAddTagValueToTransaction($input: AddTagValueToTransactionInput!) {
addTagValueToTransaction(input: $input) {
transaction {
id
status
tagValues(first: 10) {
edges {
node {
id
}
}
}
}
}
}
"""
Mutation schema (notice the ParseIDs middleware):
payload field(:add_tag_value_to_transaction) do
input do
field(:transaction_id, non_null(:id))
field(:tag_value_id, :id, deprecate: "Use tagValueIds")
field(:tag_value_ids, list_of(:id))
end
output do
field(:transaction, :transaction)
end
middleware(fn res, _ ->
res.arguments |> IO.inspect(label: :mutation_before_parse)
res
end)
middleware(ParseIDs, transaction_id: :transaction, tag_value_id: :tag_value, tag_value_ids: :tag_value)
middleware(fn res, _ ->
res.arguments |> IO.inspect(label: :mutation_after_parse)
res
end)
resolve(&TagValueResolver.add_to_transaction/2)
end
Transaction node type (notice that this :tag_values field is part of the mutation query):
The mutation returns a transaction which then requests the child tag_values field.
node object :transaction do
...
connection field(:tag_values, node_type: :tag_value, deprecate: "Use `tags` instead") do
arg(:tag_type_id, :id)
middleware(fn res, _ ->
res.arguments |> IO.inspect(label: :tags_before_parse)
res
end)
middleware(ParseIDs, tag_type_id: :tag_type)
middleware(fn res, _ ->
res.arguments |> IO.inspect(label: :tags_after_parse)
res
end)
resolve(&TransactionRecordResolver.tag_values/2)
end
...
end
find_schema_root!/2 function with inspects so you can see what the output above is looking at:
Got it. So when calling ParseIds on the connection field it's expecting things to be nested under input as if it were a payload field. Looking into it.
Absinthe Relay is the correct place for this bug, so I'm going to close this issue and open the issue in the absinthe relay repo. absinthe-graphql/absinthe_relay#162
If submitting a bug, please provide the following:
Environment
Elixir version (elixir -v):
elixir 1.10.2
erlang 22.3.4.1
Absinthe version (mix deps | grep absinthe):
absinthe (Hex package) (mix) locked at 1.5.2 (absinthe) 669c8487
absinthe_relay (Hex package) (mix) locked at 1.5.0 (absinthe_relay) 173cc44c
absinthe_sorting_codec 1.0.0 (Hex package) (mix) locked at 1.0.0 (absinthe_sorting_codec) e5dd8152
absinthe_sdl 1.1.0 (Hex package) (mix) locked at 1.1.0 (absinthe_sdl) 8b5f6293
absinthe_plug (Hex package) (mix) locked at 1.5.0 (absinthe_plug) 4c160f4c
absinthe_phoenix (Hex package) (mix) locked at 1.5.0 (absinthe_phoenix) bbe443e8
Client Framework and version (Relay, Apollo, etc):
None, this is failing from unit tests
Expected behavior
In the
ParseIDs
middleware, there is a functionfind_schema_root!/2
. I have several inspects in place to see what is going on (which I will past below). I expect to see the following happen (This works correctly on Absinthe 1.4 but not on Absinthe 1.5)I expect the
parse_ids_root
to be nil for the child fields that get resolved in the mutation.In this result (Absinthe 1.5), we see that when the ParseIDs middleware tries to parse ids for the child field, it finds the
parse_ids_root
is still set as:input
from the mutation, when it shouldn't. This behavior differs from Absinth 1.4.Basically, the first ParseIDs works great parsing the IDs from the input object generated by the mutation. However, once the graph tries to parse the child field that also contains a ParseIDs middleware call, it blows up.
This results in a runtime error:
Relevant Schema/Middleware Code
Mutation being run. There is a ParseIDs middleware call on both
:add_tag_value_to_transaction
and on:tag_values
.Mutation schema (notice the ParseIDs middleware):
Transaction node type (notice that this :tag_values field is part of the mutation query):
The mutation returns a transaction which then requests the child
tag_values
field.find_schema_root!/2
function with inspects so you can see what the output above is looking at:The text was updated successfully, but these errors were encountered: