postgraphile-plugin-connection-filter
postgraphile-plugin-connection-filter copied to clipboard
Filtering on computed table type column
Thank you for making this amazing library!
I wonder what's the reason for not supporting table types in computed columns?
https://github.com/graphile-contrib/postgraphile-plugin-connection-filter/blob/acc7d5c8c6301ba17ed1ddd427645a37a4260f29/src/PgConnectionArgFilterComputedColumnsPlugin.js#L61
I also am wondering about this, I think this is what I need.
Are there any plans to add this functionality? I also wonder whats the reason behind this. I definitely need this feature.
If someone can provide an example SQL schema and GraphQL query you'd like to see supported, I can try to dig into this.
Are you thinking of a function similar to this one from the test suite?
create function p.filterable_computed_child(f p.filterable) returns p.child as $$
select p.child.*
from p.child
where filterable_id = f.id
limit 1;
$$ language sql stable;
If so, would the intent be to allow filtering on one of more columns of p.child
?
@mattbretl It seems that I have similar problem/request.
Let's say I have following DB structure:
create table users (
id varchar NOT NULL
);
create table posts (
created_by varchar NOT NULL,
updated_by varchar
);
create function "users_postsByCreatedOrUpdatedBy"(usr users)
returns setof posts as $$
select posts.*
from posts
where usr.id = posts.created_by or usr.id = posts.updated_by
$$ language sql stable;
insert into users (id) values ('1');
insert into users (id) values ('2');
insert into users (id) values ('3');
insert into users (id) values ('4');
insert into posts (created_by, updated_by) values ('1', null);
insert into posts (created_by, updated_by) values ('3','4');
I would like to call a following query:
query MyQuery {
allUsers(filter: {postsByCreatedOrUpdatedByExist: true}) {
edges {
node {
id
}
}
}
}
I can see that the filter appears when I create the relation between created_by and user or updated_by and user, but my requirement is to find users who have created or updated at lest one post. In this example, I should see only users with ids 1
, 3
and 4
.
PS. I have explicitly set graphileBuildOptions but the Exist
filter doesn't appear when I create computed field like described above.
graphileBuildOptions: {
connectionFilterComputedColumns: true,
connectionFilterSetofFunctions: true,
connectionFilterRelations: true,
}