graphile-contrib / postgraphile-plugin-connection-filter

Filtering on PostGraphile connections
MIT License
286 stars 32 forks source link

Support for views #130

Closed jmsegrev closed 3 years ago

jmsegrev commented 4 years ago

I could not have filtering for views. I had to wrap a query to the view with a function that had a custom return type for it to work.

CREATE FUNCTION public.filter_table_view()
    RETURNS TABLE (
     id integer, 
     code character varying(50),
     name character varying(100),
     description text,
     color character varying(20),
     created_at timestamp with time zone,
    ) AS $$
        SELECT * FROM public.table_view
$$ LANGUAGE SQL STABLE;

I was looking at the tests related code and noticed that there were no views in the sql schema used. I'm assuming that its not supported yet. I'm curious about why this is the case, what are the current limitations?

apjoseph commented 4 years ago

@jmsegrev This worked for me in PostGraphileOptions:

    ignoreIndexes: true,
    graphileBuildOptions : {
        connectionFilterRelations: true
    }
mattbretl commented 3 years ago

Apologies for the reeeeally slow response time. :sweat_smile:

@jmsegrev Views should be filterable. Were you able to get it working?

jmsegrev commented 3 years ago

@mattbretl I have moved on from the project that required this feature. I'll take your word and assume it's already supported.

aakside commented 2 years ago

@mattbretl, can I add filters on view columns that aren't relations, such as a date column? Cross-post: https://discord.com/channels/489127045289476126/498852330754801666/931723651231907900