supabase+GraphiQL의 String 검색에서 like 사용 가능

supabase가 그렇게 되면 GraphiQL Filter에서 like를 사용할 수 없어요.


RestAPI에는 있지만 GraphiQL에는 like 연산자가 없습니다.그럼 안돼.

기능 추가


없는 건 어쩔 수 없으니까 하는 거야.
다음 SQL을 실행하면 GraphiQL 모드에 like가 나타납니다.
create or replace function graphql.text_to_comparison_op(text)
    returns graphql.comparison_op
    language sql
    immutable
    as
$$
    select
        case $1
            when 'eq' then '='
            when 'lt' then '<'
            when 'lte' then '<='
            when 'neq' then '<>'
            when 'gte' then '>='
            when 'gt' then '>'
            when 'like' then 'like'
            else graphql.exception('Invalid comaprison operator')
        end::graphql.comparison_op
$$;


insert into graphql._field(parent_type_id, type_id, constant_name, is_not_null, is_array, description)
    select
        gt.id as parent_type_id,
        gt.graphql_type_id type_id,
        ops.constant_name as constant_name,
        false,
        false,
        null::text as description
    from
        graphql.type gt
        join (
            values
                ('like')
        ) ops(constant_name)
            on true
    where
        gt.meta_kind = 'FilterType'
        and gt.graphql_type_id = graphql.type_id('String');

alter type graphql.comparison_op add value 'like';

ApolloStudio를 통한 모드 확인


다음은 정확하게 추가한 것이다

총결산


supabase에서 GraphiQL을 사용하는 사람은 드문 것 같은데, 어려운 친구를 도와주면 좋겠어요.

좋은 웹페이지 즐겨찾기