Skip to content

Commit

Permalink
Merge pull request #544 from supabase/fix_comment_directive_parsing
Browse files Browse the repository at this point in the history
fix a bug in which a closing parenthesis in @graphql directive failed to parse as json
  • Loading branch information
olirice authored Jul 12, 2024
2 parents 0b1c39b + 064ae81 commit d1acb1b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sql/directives.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ as $$
(
regexp_match(
comment_,
'@graphql\((.+?)\)'
'@graphql\((.+)\)'
)
)[1]::jsonb,
jsonb_build_object()
Expand Down
29 changes: 28 additions & 1 deletion test/expected/comment_directive.out
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
select
graphql.comment_directive(
comment_ := '@graphql({"name": "myField"})'
)
);
comment_directive
---------------------
{"name": "myField"}
(1 row)

select
graphql.comment_directive(
comment_ := '@graphql({"name": "myField with (parentheses)"})'
);
comment_directive
----------------------------------------
{"name": "myField with (parentheses)"}
(1 row)

select
graphql.comment_directive(
comment_ := '@graphql({"name": "myField with a (starting parenthesis"})'
);
comment_directive
--------------------------------------------------
{"name": "myField with a (starting parenthesis"}
(1 row)

select
graphql.comment_directive(
comment_ := '@graphql({"name": "myField with an ending parenthesis)"})'
);
comment_directive
-------------------------------------------------
{"name": "myField with an ending parenthesis)"}
(1 row)

17 changes: 16 additions & 1 deletion test/sql/comment_directive.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
select
graphql.comment_directive(
comment_ := '@graphql({"name": "myField"})'
)
);

select
graphql.comment_directive(
comment_ := '@graphql({"name": "myField with (parentheses)"})'
);

select
graphql.comment_directive(
comment_ := '@graphql({"name": "myField with a (starting parenthesis"})'
);

select
graphql.comment_directive(
comment_ := '@graphql({"name": "myField with an ending parenthesis)"})'
);

0 comments on commit d1acb1b

Please sign in to comment.