graphile / graphile/crystal

PgSelect step is not deduplicating

Open
#2,303 4 comments 0 reactions 0 assignees View on GitHub
💅 enhancement
Dominant language
TypeScript
Stars
12.9k
Forks
625
Avg merge
5h 23m
Merged PRs (30d)
24

Description

### Summary

When doing `xByRowId` queries with the same constant ID, pgSelect step does not seem to correctly deduplicate

![Screenshot 2025-01-06 at 12 00 37 PM](https://github.com/user-attachments/assets/11b2cdd4-5a9b-4cb1-b593-76a859e37f08)

### Steps to reproduce

Setup Postgraphile v5. Add a table with the ability to do a root query to fetch a single row of that table by its row ID

```sql
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.

```gql
query MyFoos {
foo1: foo(id="1") {
id
}
foo2: foo(id="1") {
id
}
}
```

See the diagram of the plan is similar to the screenshot above

Please let me know if it would be useful to create a minimal repro of this. I'm happy to do so

### Expected results

I expect there to be a single PgSelect step in the plan

### Actual results

There are 2 PgSelect steps

### Additional context

Additional discussion in this discord thread:

https://discord.com/channels/489127045289476126/1325736426587033652/1325879877576032288

### Possible Solution

Not sure without digging into PgSelect code

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.