Inconsistent handling of optional filter variables for `SETOF SQL` functions gives "Encountered Absent value" error

Aperta
#617 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@olirice ci sta già lavorando.

Dal 12/12/2025.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

triage-required

This is a cool project, appreciate the work gone into it. I ran into a small behavior that seems inconsistent, and I wanted to share a reproducible example to clarify what I observed.

Describe the bug

SQL functions that return SETOF <table> are exposed as GraphQL collections, making it possible to use the filter argument and more. However, the handling of optional filter variables is inconsistent compared to normal table collections:

  • For normal table collections, omitted filter variables are silently ignored (filter clause removed).
  • For function collections, if a filter variable is not provided (omitted from the GraphQL variables JSON), pg_graphql sometimes throws:
Encountered `Absent` value while transforming between GraphQL intermediate object notation and JSON

To Reproduce

Create dummy table and function:

create table dummy_table (
  id serial primary key,
  category text
);

create or replace function dummy_function ()
  returns setof dummy_table as $$
    select t.*
    from dummy_table t
$$ stable language sql;

insert into dummy_table (category) values
  ('CAT A'),
  ('CAT B'),
  ('CAT C');

Query the table

  • Try querying the new table collection with variables: {}. It works fine.
{
  dummy_tableCollection(filter: {category: {eq: $filter_category}}) {
    edges {
      node {
        id
        category
      }
    }
  }
}

Query the function

  • Try querying the new function now with variables: {}. It produces the "Absent" error.
  • Try querying with variables: { "filter_category": "CAT A" }, it works as expected doing the expected filtering.
{
  dummy_function(filter: {category: {eq: $filter_category}}) {
     edges {
      node {
        id
        category
      }
    }
  }
}

Expected behavior
Optional filter variables in function collections should behave like table collections:

  • If the variable is omitted, the filter should be ignored rather than producing an Absent error.

Versions:

  • PostgreSQL: 15
  • pg_graphql version: 1.5.11
Lingua principale
Rust
Stelle
3.4k
Fork
142
Merge medio
5h 26m
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di supabase/pg_graphql

Tutte le issue di supabase/pg_graphql

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.