From 546e15f7e06f790fb04003886c4003e1168ca7a6 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Mon, 7 Sep 2020 08:50:20 +0800 Subject: [PATCH] Do not strengthen module type! --- .gitignore | 1 + documentation/docs/changelog.md | 18 +++++++++- package.json | 2 +- .../output_bucklescript_module.re | 21 ++++++++++- ...e_Apollo_extensions_re.c4a6997e.0.snapshot | 36 ++----------------- ..._Objects_extensions_re.b512b846.0.snapshot | 36 ++----------------- ..._Records_extensions_re.330a7e2a.0.snapshot | 34 ++---------------- ...Template_extensions_re.2d765912.0.snapshot | 34 ++---------------- 8 files changed, 51 insertions(+), 131 deletions(-) diff --git a/.gitignore b/.gitignore index 933bd45f..283b2e69 100755 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ npm-debug.log *.cmj *.cmt .vscode +.vim diff --git a/documentation/docs/changelog.md b/documentation/docs/changelog.md index de709304..8d7576fb 100644 --- a/documentation/docs/changelog.md +++ b/documentation/docs/changelog.md @@ -14,7 +14,23 @@ title: Changelog (_Tags are copied from [babel](https://github.com/babel/babel/blob/master/CHANGELOG.md)_) -## [1.0.0](https://github.com/reasonml-community/graphql_ppx/compare/legacy...master) (in beta) +## [1.0.1](https://github.com/reasonml-community/graphql_ppx/compare/v1.0.0...v1.0.1) (2020-09-07) + +- :bug: remove `@ppxConfig` directive from query output + ([b697b83](https://github.com/reasonml-community/graphql_ppx/commit/b697b83)) + +- :bug: do not strengthen module type of extended module to prevent type errors + like below when the the definition is being extended + ([4ae9895](https://github.com/reasonml-community/graphql_ppx/commit/4ae9895)) + +``` +This has type: + MyQuery.t_variables +But somewhere wanted: + MyQuery.MyQuery_inner.t_variables +``` + +## [1.0.0](https://github.com/reasonml-community/graphql_ppx/compare/v0.7.2...v1.0.0) (2020-09-06) There has been a lot of new features in version 1.0 of `graphql-ppx`. Below some of the main changes. After 1.0 we are going to record a more detailed changelog. diff --git a/package.json b/package.json index 4b175f49..307ac6f8 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@reasonml-community/graphql-ppx", - "version": "1.0.0", + "version": "1.0.1", "description": "graphql-ppx rewriter for Bucklescript/ReasonML", "repository": "https://github.com/reasonml-community/graphql-ppx", "author": "Tomasz Cichocinski ", diff --git a/src/bucklescript/output_bucklescript_module.re b/src/bucklescript/output_bucklescript_module.re index 23bd1f17..c8b7c6a3 100644 --- a/src/bucklescript/output_bucklescript_module.re +++ b/src/bucklescript/output_bucklescript_module.re @@ -448,7 +448,26 @@ let wrap_query_module = let signature = List.concat([ [signature_module(module_name, signature)], - signature, + [ + Sig.include_( + Incl.mk( + Mty.typeof_( + Mod.mk( + Pmod_structure([ + Str.include_( + Incl.mk( + Mod.ident({ + txt: Longident.parse(module_name), + loc, + }), + ), + ), + ]), + ), + ), + ), + ), + ], [ Sig.include_( Incl.mk( diff --git a/tests_bucklescript/__snapshots__/Generate_Apollo_extensions_re.c4a6997e.0.snapshot b/tests_bucklescript/__snapshots__/Generate_Apollo_extensions_re.c4a6997e.0.snapshot index e2d495ce..24716687 100644 --- a/tests_bucklescript/__snapshots__/Generate_Apollo_extensions_re.c4a6997e.0.snapshot +++ b/tests_bucklescript/__snapshots__/Generate_Apollo_extensions_re.c4a6997e.0.snapshot @@ -71,39 +71,9 @@ function back to the original JSON compatible data */ external toJson: Raw.t => Js.Json.t = \"%identity\"; external variablesToJson: Raw.t_variables => Js.Json.t = \"%identity\"; }; - module Raw: { - type t_lists = { - __typename: string, - nullableOfNullable: Js.Nullable.t(array(Js.Nullable.t(string))), - nullableOfNonNullable: Js.Nullable.t(array(string)), - nonNullableOfNullable: array(Js.Nullable.t(string)), - nonNullableOfNonNullable: array(string), - }; - type t = {lists: t_lists}; - type t_variables = unit; - }; - type t_lists = { - __typename: string, - nullableOfNullable: option(array(option(string))), - nullableOfNonNullable: option(array(string)), - nonNullableOfNullable: array(option(string)), - nonNullableOfNonNullable: array(string), - }; - type t = {lists: t_lists}; - type t_variables = unit; - /** The GraphQL query */ - let query: string; - /** Parse the JSON-compatible GraphQL data to ReasonML data types */ - let parse: Raw.t => t; - /** Serialize the ReasonML GraphQL data that was parsed using the parse -function back to the original JSON compatible data */ - let serialize: t => Raw.t; - let serializeVariables: unit => unit; - let makeVariables: unit => unit; - let makeDefaultVariables: unit => t_variables; - external unsafe_fromJson: Js.Json.t => Raw.t = \"%identity\"; - external toJson: Raw.t => Js.Json.t = \"%identity\"; - external variablesToJson: Raw.t_variables => Js.Json.t = \"%identity\"; + include (module type of { + include Bla_inner; + }); include (module type of { include Parent.ExtendQuery(Bla_inner); }); diff --git a/tests_bucklescript/__snapshots__/Generate_Objects_extensions_re.b512b846.0.snapshot b/tests_bucklescript/__snapshots__/Generate_Objects_extensions_re.b512b846.0.snapshot index 2c980cdc..b565f5d6 100644 --- a/tests_bucklescript/__snapshots__/Generate_Objects_extensions_re.b512b846.0.snapshot +++ b/tests_bucklescript/__snapshots__/Generate_Objects_extensions_re.b512b846.0.snapshot @@ -71,39 +71,9 @@ function back to the original JSON compatible data */ external toJson: Raw.t => Js.Json.t = \"%identity\"; external variablesToJson: Raw.t_variables => Js.Json.t = \"%identity\"; }; - module Raw: { - type t_lists = { - . - \"nullableOfNullable\": Js.Nullable.t(array(Js.Nullable.t(string))), - \"nullableOfNonNullable\": Js.Nullable.t(array(string)), - \"nonNullableOfNullable\": array(Js.Nullable.t(string)), - \"nonNullableOfNonNullable\": array(string), - }; - type t = {. \"lists\": t_lists}; - type t_variables = unit; - }; - type t_lists = { - . - \"nullableOfNullable\": option(array(option(string))), - \"nullableOfNonNullable\": option(array(string)), - \"nonNullableOfNullable\": array(option(string)), - \"nonNullableOfNonNullable\": array(string), - }; - type t = {. \"lists\": t_lists}; - type t_variables = unit; - /** The GraphQL query */ - let query: string; - /** Parse the JSON-compatible GraphQL data to ReasonML data types */ - let parse: Raw.t => t; - /** Serialize the ReasonML GraphQL data that was parsed using the parse -function back to the original JSON compatible data */ - let serialize: t => Raw.t; - let serializeVariables: unit => unit; - let makeVariables: unit => unit; - let makeDefaultVariables: unit => t_variables; - external unsafe_fromJson: Js.Json.t => Raw.t = \"%identity\"; - external toJson: Raw.t => Js.Json.t = \"%identity\"; - external variablesToJson: Raw.t_variables => Js.Json.t = \"%identity\"; + include (module type of { + include Bla_inner; + }); include (module type of { include Parent.ExtendQuery(Bla_inner); }); diff --git a/tests_bucklescript/__snapshots__/Generate_Records_extensions_re.330a7e2a.0.snapshot b/tests_bucklescript/__snapshots__/Generate_Records_extensions_re.330a7e2a.0.snapshot index 74c99b40..e189ed0e 100644 --- a/tests_bucklescript/__snapshots__/Generate_Records_extensions_re.330a7e2a.0.snapshot +++ b/tests_bucklescript/__snapshots__/Generate_Records_extensions_re.330a7e2a.0.snapshot @@ -69,37 +69,9 @@ function back to the original JSON compatible data */ external toJson: Raw.t => Js.Json.t = \"%identity\"; external variablesToJson: Raw.t_variables => Js.Json.t = \"%identity\"; }; - module Raw: { - type t_lists = { - nullableOfNullable: Js.Nullable.t(array(Js.Nullable.t(string))), - nullableOfNonNullable: Js.Nullable.t(array(string)), - nonNullableOfNullable: array(Js.Nullable.t(string)), - nonNullableOfNonNullable: array(string), - }; - type t = {lists: t_lists}; - type t_variables = unit; - }; - type t_lists = { - nullableOfNullable: option(array(option(string))), - nullableOfNonNullable: option(array(string)), - nonNullableOfNullable: array(option(string)), - nonNullableOfNonNullable: array(string), - }; - type t = {lists: t_lists}; - type t_variables = unit; - /** The GraphQL query */ - let query: string; - /** Parse the JSON-compatible GraphQL data to ReasonML data types */ - let parse: Raw.t => t; - /** Serialize the ReasonML GraphQL data that was parsed using the parse -function back to the original JSON compatible data */ - let serialize: t => Raw.t; - let serializeVariables: unit => unit; - let makeVariables: unit => unit; - let makeDefaultVariables: unit => t_variables; - external unsafe_fromJson: Js.Json.t => Raw.t = \"%identity\"; - external toJson: Raw.t => Js.Json.t = \"%identity\"; - external variablesToJson: Raw.t_variables => Js.Json.t = \"%identity\"; + include (module type of { + include Bla_inner; + }); include (module type of { include Parent.ExtendQuery(Bla_inner); }); diff --git a/tests_bucklescript/__snapshots__/Generate_Template_extensions_re.2d765912.0.snapshot b/tests_bucklescript/__snapshots__/Generate_Template_extensions_re.2d765912.0.snapshot index 3ccc9a11..7d1caae1 100644 --- a/tests_bucklescript/__snapshots__/Generate_Template_extensions_re.2d765912.0.snapshot +++ b/tests_bucklescript/__snapshots__/Generate_Template_extensions_re.2d765912.0.snapshot @@ -69,37 +69,9 @@ function back to the original JSON compatible data */ external toJson: Raw.t => Js.Json.t = \"%identity\"; external variablesToJson: Raw.t_variables => Js.Json.t = \"%identity\"; }; - module Raw: { - type t_lists = { - nullableOfNullable: Js.Nullable.t(array(Js.Nullable.t(string))), - nullableOfNonNullable: Js.Nullable.t(array(string)), - nonNullableOfNullable: array(Js.Nullable.t(string)), - nonNullableOfNonNullable: array(string), - }; - type t = {lists: t_lists}; - type t_variables = unit; - }; - type t_lists = { - nullableOfNullable: option(array(option(string))), - nullableOfNonNullable: option(array(string)), - nonNullableOfNullable: array(option(string)), - nonNullableOfNonNullable: array(string), - }; - type t = {lists: t_lists}; - type t_variables = unit; - /** The GraphQL query */ - let query: string; - /** Parse the JSON-compatible GraphQL data to ReasonML data types */ - let parse: Raw.t => t; - /** Serialize the ReasonML GraphQL data that was parsed using the parse -function back to the original JSON compatible data */ - let serialize: t => Raw.t; - let serializeVariables: unit => unit; - let makeVariables: unit => unit; - let makeDefaultVariables: unit => t_variables; - external unsafe_fromJson: Js.Json.t => Raw.t = \"%identity\"; - external toJson: Raw.t => Js.Json.t = \"%identity\"; - external variablesToJson: Raw.t_variables => Js.Json.t = \"%identity\"; + include (module type of { + include Bla_inner; + }); include (module type of { include Parent.ExtendQuery(Bla_inner); });