From 79d140a58dca9c1085df39e6b891d48b5b8eaa42 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 17 May 2024 23:39:08 +0200 Subject: [PATCH] Filter out ppxAllowStringReturnType --- .../fragmentWithdifferentReturnType.res.txt | 2 +- .../fragmentWithdifferentReturnType.res.txt | 2 +- .../fragmentWithdifferentReturnType.res.txt | 2 +- .../fragmentWithdifferentReturnType.res.txt | 2 +- .../fragmentWithdifferentReturnType.res.txt | 2 +- .../fragmentWithdifferentReturnType.res.txt | 2 +- .../fragmentWithdifferentReturnType.res.txt | 2 +- .../fragmentWithdifferentReturnType.res.txt | 2 +- .../fragmentWithdifferentReturnType.res.txt | 2 +- src/graphql_compiler/graphql_printer.ml | 15 +++++++-------- 10 files changed, 16 insertions(+), 17 deletions(-) diff --git a/snapshot_tests/operations/expected/apollo/compile/fragmentWithdifferentReturnType.res.txt b/snapshot_tests/operations/expected/apollo/compile/fragmentWithdifferentReturnType.res.txt index b210e731..bdaf4da8 100644 --- a/snapshot_tests/operations/expected/apollo/compile/fragmentWithdifferentReturnType.res.txt +++ b/snapshot_tests/operations/expected/apollo/compile/fragmentWithdifferentReturnType.res.txt @@ -66,7 +66,7 @@ var Raw$1 = {}; var query$1 = Gql`query MyQuery { lists { -...ListFragment @ppxAllowStringReturnType +...ListFragment } } diff --git a/snapshot_tests/operations/expected/apollo/generate/fragmentWithdifferentReturnType.res.txt b/snapshot_tests/operations/expected/apollo/generate/fragmentWithdifferentReturnType.res.txt index 67cb1581..e379a226 100644 --- a/snapshot_tests/operations/expected/apollo/generate/fragmentWithdifferentReturnType.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/fragmentWithdifferentReturnType.res.txt @@ -136,7 +136,7 @@ function back to the original JSON compatible data ") [ "query MyQuery { lists { -...ListFragment @ppxAllowStringReturnType +...ListFragment } } diff --git a/snapshot_tests/operations/expected/native/generate/fragmentWithdifferentReturnType.res.txt b/snapshot_tests/operations/expected/native/generate/fragmentWithdifferentReturnType.res.txt index 67cb1581..e379a226 100644 --- a/snapshot_tests/operations/expected/native/generate/fragmentWithdifferentReturnType.res.txt +++ b/snapshot_tests/operations/expected/native/generate/fragmentWithdifferentReturnType.res.txt @@ -136,7 +136,7 @@ function back to the original JSON compatible data ") [ "query MyQuery { lists { -...ListFragment @ppxAllowStringReturnType +...ListFragment } } diff --git a/snapshot_tests/operations/expected/records/compile/fragmentWithdifferentReturnType.res.txt b/snapshot_tests/operations/expected/records/compile/fragmentWithdifferentReturnType.res.txt index aafa86b6..7218a0d0 100644 --- a/snapshot_tests/operations/expected/records/compile/fragmentWithdifferentReturnType.res.txt +++ b/snapshot_tests/operations/expected/records/compile/fragmentWithdifferentReturnType.res.txt @@ -63,7 +63,7 @@ var Raw$1 = {}; var query$1 = Gql`query MyQuery { lists { -...ListFragment @ppxAllowStringReturnType +...ListFragment } } diff --git a/snapshot_tests/operations/expected/records/generate/fragmentWithdifferentReturnType.res.txt b/snapshot_tests/operations/expected/records/generate/fragmentWithdifferentReturnType.res.txt index 67cb1581..e379a226 100644 --- a/snapshot_tests/operations/expected/records/generate/fragmentWithdifferentReturnType.res.txt +++ b/snapshot_tests/operations/expected/records/generate/fragmentWithdifferentReturnType.res.txt @@ -136,7 +136,7 @@ function back to the original JSON compatible data ") [ "query MyQuery { lists { -...ListFragment @ppxAllowStringReturnType +...ListFragment } } diff --git a/snapshot_tests/operations/expected/template/compile/fragmentWithdifferentReturnType.res.txt b/snapshot_tests/operations/expected/template/compile/fragmentWithdifferentReturnType.res.txt index 8a96f2cd..1c168b74 100644 --- a/snapshot_tests/operations/expected/template/compile/fragmentWithdifferentReturnType.res.txt +++ b/snapshot_tests/operations/expected/template/compile/fragmentWithdifferentReturnType.res.txt @@ -67,7 +67,7 @@ var Raw$1 = {}; var query$1 = Gql`query MyQuery { lists { -...ListFragment @ppxAllowStringReturnType +...ListFragment } } diff --git a/snapshot_tests/operations/expected/template/generate/fragmentWithdifferentReturnType.res.txt b/snapshot_tests/operations/expected/template/generate/fragmentWithdifferentReturnType.res.txt index 67cb1581..e379a226 100644 --- a/snapshot_tests/operations/expected/template/generate/fragmentWithdifferentReturnType.res.txt +++ b/snapshot_tests/operations/expected/template/generate/fragmentWithdifferentReturnType.res.txt @@ -136,7 +136,7 @@ function back to the original JSON compatible data ") [ "query MyQuery { lists { -...ListFragment @ppxAllowStringReturnType +...ListFragment } } diff --git a/snapshot_tests/operations/expected/uncurried/compile/fragmentWithdifferentReturnType.res.txt b/snapshot_tests/operations/expected/uncurried/compile/fragmentWithdifferentReturnType.res.txt index 781e79b4..956d928c 100644 --- a/snapshot_tests/operations/expected/uncurried/compile/fragmentWithdifferentReturnType.res.txt +++ b/snapshot_tests/operations/expected/uncurried/compile/fragmentWithdifferentReturnType.res.txt @@ -63,7 +63,7 @@ var Raw$1 = {}; var query$1 = Gql`query MyQuery { lists { -...ListFragment @ppxAllowStringReturnType +...ListFragment } } diff --git a/snapshot_tests/operations/expected/uncurried/generate/fragmentWithdifferentReturnType.res.txt b/snapshot_tests/operations/expected/uncurried/generate/fragmentWithdifferentReturnType.res.txt index 67cb1581..e379a226 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/fragmentWithdifferentReturnType.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/fragmentWithdifferentReturnType.res.txt @@ -136,7 +136,7 @@ function back to the original JSON compatible data ") [ "query MyQuery { lists { -...ListFragment @ppxAllowStringReturnType +...ListFragment } } diff --git a/src/graphql_compiler/graphql_printer.ml b/src/graphql_compiler/graphql_printer.ml index f13d7f8f..c231f698 100644 --- a/src/graphql_compiler/graphql_printer.ml +++ b/src/graphql_compiler/graphql_printer.ml @@ -53,14 +53,13 @@ let print_directive d = | None -> "" let is_internal_directive d = - match d.item.d_name.item with - | "bsOmitFutureValue" | "ppxOmitFutureValue" | "bsVariant" | "ppxVariant" - | "bsRecord" | "ppxRecord" | "bsObject" | "ppxObject" | "bsDecoder" - | "ppxDecoder" | "bsCustom" | "ppxCustom" | "ppxCustomOpt" | "bsAs" | "ppxAs" - | "argumentDefinitions" | "arguments" | "bsField" | "ppxField" | "ppxConfig" - -> - true - | _ -> false + let name = d.item.d_name.item in + if + String.starts_with ~prefix:"bs" name + || String.starts_with ~prefix:"ppx" name + then true + else + match name with "argumentDefinitions" | "arguments" -> true | _ -> false let print_directives ds = " "