From a41dc7cc0936e40da5663ee0770d79374ddc3d78 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Sat, 28 Mar 2020 23:26:31 +0800 Subject: [PATCH] Add relay option to the configuration --- src/base/ppx_config.re | 2 ++ src/bucklescript/graphql_ppx.re | 16 +++++++++++++--- src/native/graphql_ppx.re | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/base/ppx_config.re b/src/base/ppx_config.re index e4c55adf..455fa1e1 100644 --- a/src/base/ppx_config.re +++ b/src/base/ppx_config.re @@ -16,6 +16,7 @@ type config = { template_tag: option(string), template_tag_location: option(string), template_tag_import: option(string), + relay: bool, }; let config_ref = ref(None); @@ -34,6 +35,7 @@ let apollo_mode = () => (config_ref^ |> Option.unsafe_unwrap).apollo_mode; let records = () => (config_ref^ |> Option.unsafe_unwrap).records; let legacy = () => (config_ref^ |> Option.unsafe_unwrap).legacy; let definition = () => (config_ref^ |> Option.unsafe_unwrap).definition; +let relay = () => (config_ref^ |> Option.unsafe_unwrap).relay; let template_tag = () => (config_ref^ |> Option.unsafe_unwrap).template_tag; let template_tag_import = () => diff --git a/src/bucklescript/graphql_ppx.re b/src/bucklescript/graphql_ppx.re index 3ea54c56..17078ad5 100644 --- a/src/bucklescript/graphql_ppx.re +++ b/src/bucklescript/graphql_ppx.re @@ -46,6 +46,7 @@ let legacy = () => Ppx_config.legacy(); let global_template_tag = () => Ppx_config.template_tag(); let global_template_tag_import = () => Ppx_config.template_tag_import(); let global_template_tag_location = () => Ppx_config.template_tag_location(); +let global_relay = () => Ppx_config.relay(); let fmt_parse_err = err => Graphql_parser.( @@ -250,6 +251,7 @@ let get_query_config = fields => { tagged_template: extract_tagged_template_config(fields), }; }; + let empty_query_config = { schema: None, records: None, @@ -418,6 +420,7 @@ let () = template_tag_location: None, template_tag_import: None, definition: true, + relay: false, }) ); @@ -709,7 +712,7 @@ let args = [ () => Ppx_config.update_config(current => {...current, definition: false}), ), - "Legacy mode (make and makeWithVariables)", + "Do not generate a definition", ), ( "-template-tag", @@ -719,7 +722,7 @@ let args = [ {...current, template_tag: Some(template_tag)} ), ), - "Template tag to use", + "Name of the template tag to use", ), ( "-template-tag-import", @@ -729,7 +732,7 @@ let args = [ {...current, template_tag_import: Some(template_tag_import)} ), ), - "the import to use for the template tag (default is \"default\"", + "the import to use for the template tag (default is \"default\")", ), ( "-template-tag-location", @@ -741,6 +744,13 @@ let args = [ ), "the import location for the template tag (default is \"default\"", ), + ( + "-relay", + Arg.Unit( + () => Ppx_config.update_config(current => {...current, relay: true}), + ), + "Relay mode", + ), ]; let () = diff --git a/src/native/graphql_ppx.re b/src/native/graphql_ppx.re index 93808b2e..c2e45ca8 100644 --- a/src/native/graphql_ppx.re +++ b/src/native/graphql_ppx.re @@ -196,6 +196,7 @@ let () = template_tag: None, template_tag_location: None, template_tag_import: None, + relay: false, }) );