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

NodeAccessorPlugin spec does not deduplicate #2302

Open
jcgsville opened this issue Jan 6, 2025 · 0 comments
Open

NodeAccessorPlugin spec does not deduplicate #2302

jcgsville opened this issue Jan 6, 2025 · 0 comments

Comments

@jcgsville
Copy link
Contributor

Summary

When using the xByNodeId queries, the plan does not correctly deduplicate equivalent constants.

Screenshot 2025-01-06 at 11 52 37 AM

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.

create table foo (id int primary 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.

query MyFoos {
  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 🙂

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

@github-project-automation github-project-automation bot moved this to 🌳 Triage in V5.0.0 Jan 6, 2025
@benjie benjie moved this from 🌳 Triage to 🦟 Mayfly in V5.0.0 Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🦟 Mayfly
Development

No branches or pull requests

2 participants