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
When using the xByNodeId queries, the plan does not correctly deduplicate equivalent constants.
Steps to reproduce
Setup Postgraphile v5 with the relay preset. Add a table with the ability to do a root query to fetch a single row of that table by its node ID. e.g.
createtablefoo (id intprimary key, a text);
Set graphile.explain to true in your preset
Execute a query in Ruru using aliases to query the same row twice. e.g.
queryMyFoos {
foo1: fooById(id="asdfasdf") {
id
}
foo2: fooById(id="asdfasdf") {
id
}
}
See the diagram of the plan is similar to the screenshot above
If necessary, I can create a minimal repro of this, but it's probably not necessary, because I'd like to tackle the issue, and I have a repro on my project 🙂
According to @benjie, the specForHandler function here incorrectly returns a new function each time. Thus the lambda() here cannot deduplicate because the functions are not equivalent. We could potentially cache the function in a Map such that the functions are equivalent, and lambda() can deduplicate
The text was updated successfully, but these errors were encountered:
Summary
When using the
xByNodeId
queries, the plan does not correctly deduplicate equivalent constants.Steps to reproduce
Setup Postgraphile v5 with the relay preset. Add a table with the ability to do a root query to fetch a single row of that table by its node ID. e.g.
Set
graphile.explain
totrue
in your presetExecute a query in Ruru using aliases to query the same row twice. e.g.
See the diagram of the plan is similar to the screenshot above
If necessary, I can create a minimal repro of this, but it's probably not necessary, because I'd like to tackle the issue, and I have a repro on my project 🙂
Expected results
I'd expect to see only a single Lambda step
Actual results
I see two Lambda steps
Additional context
Discussed here
https://discord.com/channels/489127045289476126/1325736426587033652/1325877404559740959
Possible Solution
According to @benjie, the specForHandler function here incorrectly returns a new function each time. Thus the lambda() here cannot deduplicate because the functions are not equivalent. We could potentially cache the function in a Map such that the functions are equivalent, and lambda() can deduplicate
The text was updated successfully, but these errors were encountered: