Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Relay support #97

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/base/ppx_config.re
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 = () =>
Expand Down
16 changes: 13 additions & 3 deletions src/bucklescript/graphql_ppx.re
Original file line number Diff line number Diff line change
Expand Up @@ -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.(
Expand Down Expand Up @@ -250,6 +251,7 @@ let get_query_config = fields => {
tagged_template: extract_tagged_template_config(fields),
};
};

let empty_query_config = {
schema: None,
records: None,
Expand Down Expand Up @@ -418,6 +420,7 @@ let () =
template_tag_location: None,
template_tag_import: None,
definition: true,
relay: false,
})
);

Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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 () =
Expand Down
1 change: 1 addition & 0 deletions src/native/graphql_ppx.re
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ let () =
template_tag: None,
template_tag_location: None,
template_tag_import: None,
relay: false,
})
);

Expand Down