diff --git a/packages/rescript-relay/rescript-relay-ppx/library/Query.ml b/packages/rescript-relay/rescript-relay-ppx/library/Query.ml index a71d4262..d204ac82 100644 --- a/packages/rescript-relay/rescript-relay-ppx/library/Query.ml +++ b/packages/rescript-relay/rescript-relay-ppx/library/Query.ml @@ -9,84 +9,80 @@ let make ~loc ~moduleName ~hasRawResponseType ~hasAutocodesplitDirective = (Pmod_structure (List.concat [ - ([ - [%stri [@@@ocaml.warning "-32-34-60"]]; - [%stri include [%m moduleIdentFromGeneratedModule ["Utils"]]]; - [%stri module Operation = [%m moduleIdentFromGeneratedModule []]]; - [%stri - module Types = [%m moduleIdentFromGeneratedModule ["Types"]]]; - [%stri - let convertVariables : - [%t typeFromGeneratedModule ["Types"; "variables"]] -> - [%t typeFromGeneratedModule ["Types"; "variables"]] = - [%e valFromGeneratedModule ["Internal"; "convertVariables"]]]; - [%stri - let convertResponse : - [%t typeFromGeneratedModule ["Types"; "response"]] -> - [%t typeFromGeneratedModule ["Types"; "response"]] = - [%e valFromGeneratedModule ["Internal"; "convertResponse"]]]; - [%stri - let convertWrapRawResponse : - [%t typeFromGeneratedModule ["Types"; "rawResponse"]] -> - [%t typeFromGeneratedModule ["Types"; "rawResponse"]] = - [%e - valFromGeneratedModule - ["Internal"; "convertWrapRawResponse"]]]; - [%stri - external mkQueryRefOpt : - [%t typeFromGeneratedModule ["queryRef"]] option -> - [%t typeFromGeneratedModule ["queryRef"]] option - = "%identity"]; - [%stri - external mkQueryRef : - [%t typeFromGeneratedModule ["queryRef"]] -> - [%t typeFromGeneratedModule ["queryRef"]] = "%identity"]; - ] - @ - if not !NonReactUtils.enabled then - [ + [ + [%stri [@@@ocaml.warning "-32-34-60"]]; + [%stri include [%m moduleIdentFromGeneratedModule ["Utils"]]]; + [%stri module Operation = [%m moduleIdentFromGeneratedModule []]]; + [%stri + module Types = [%m moduleIdentFromGeneratedModule ["Types"]]]; + [%stri + let convertVariables : + [%t typeFromGeneratedModule ["Types"; "variables"]] -> + [%t typeFromGeneratedModule ["Types"; "variables"]] = + [%e valFromGeneratedModule ["Internal"; "convertVariables"]]]; + [%stri + let convertResponse : + [%t typeFromGeneratedModule ["Types"; "response"]] -> + [%t typeFromGeneratedModule ["Types"; "response"]] = + [%e valFromGeneratedModule ["Internal"; "convertResponse"]]]; + [%stri + let convertWrapRawResponse : + [%t typeFromGeneratedModule ["Types"; "rawResponse"]] -> + [%t typeFromGeneratedModule ["Types"; "rawResponse"]] = + [%e + valFromGeneratedModule + ["Internal"; "convertWrapRawResponse"]]]; + [%stri + external mkQueryRefOpt : + [%t typeFromGeneratedModule ["queryRef"]] option -> + [%t typeFromGeneratedModule ["queryRef"]] option = "%identity"]; + [%stri + external mkQueryRef : + [%t typeFromGeneratedModule ["queryRef"]] -> + [%t typeFromGeneratedModule ["queryRef"]] = "%identity"]; + ] + @ (if not !NonReactUtils.enabled then + [ + [%stri + let use = + RescriptRelay_Query.useQuery ~convertVariables + ~convertResponse + ~node:[%e valFromGeneratedModule ["node"]]]; + [%stri + let useLoader = + RescriptRelay_Query.useLoader ~convertVariables + ~mkQueryRef:mkQueryRefOpt + ~node:[%e valFromGeneratedModule ["node"]]]; + [%stri + let usePreloaded = + RescriptRelay_Query.usePreloaded ~convertResponse + ~mkQueryRef + ~node:[%e valFromGeneratedModule ["node"]]]; + ] + else []) + @ [ [%stri - let use = - RescriptRelay_Query.useQuery ~convertVariables - ~convertResponse + let fetch = + RescriptRelay_Query.fetch ~convertResponse ~convertVariables ~node:[%e valFromGeneratedModule ["node"]]]; [%stri - let useLoader = - RescriptRelay_Query.useLoader ~convertVariables - ~mkQueryRef:mkQueryRefOpt + let fetchPromised = + RescriptRelay_Query.fetchPromised ~convertResponse + ~convertVariables ~node:[%e valFromGeneratedModule ["node"]]]; [%stri - let usePreloaded = - RescriptRelay_Query.usePreloaded ~convertResponse - ~mkQueryRef + let retain = + RescriptRelay_Query.retain ~convertVariables ~node:[%e valFromGeneratedModule ["node"]]]; - ] - else - [] - @ [ - [%stri - let fetch = - RescriptRelay_Query.fetch ~convertResponse - ~convertVariables - ~node:[%e valFromGeneratedModule ["node"]]]; - [%stri - let fetchPromised = - RescriptRelay_Query.fetchPromised ~convertResponse - ~convertVariables - ~node:[%e valFromGeneratedModule ["node"]]]; + (match hasRawResponseType with + | true -> [%stri - let retain = - RescriptRelay_Query.retain ~convertVariables - ~node:[%e valFromGeneratedModule ["node"]]]; - (match hasRawResponseType with - | true -> - [%stri - let commitLocalPayload = - RescriptRelay_Query.commitLocalPayload ~convertVariables - ~convertWrapRawResponse - ~node:[%e valFromGeneratedModule ["node"]]] - | false -> [%stri ()]); - ]); + let commitLocalPayload = + RescriptRelay_Query.commitLocalPayload ~convertVariables + ~convertWrapRawResponse + ~node:[%e valFromGeneratedModule ["node"]]] + | false -> [%stri ()]); + ]; (match (!NonReactUtils.enabled, hasAutocodesplitDirective) with | true, _ -> [] | false, true ->