From 155779699eb154a4e4d51059be39ae219f13513f Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Fri, 17 May 2024 10:23:13 +0200 Subject: [PATCH] snapshot differences --- .../apollo/generate/argNamedQuery.res.txt | 18 +- .../expected/apollo/generate/comment.res.txt | 184 ++++----- .../apollo/generate/customScalars.res.txt | 22 +- .../apollo/generate/customTypes.res.txt | 34 +- .../apollo/generate/enumInput.res.txt | 22 +- .../generate/fragmentDefinition.res.txt | 20 +- .../apollo/generate/fragmentUnion.res.txt | 10 +- .../apollo/generate/hasuraRepro.res.txt | 34 +- .../apollo/generate/listsArgs.res.txt | 86 ++-- .../apollo/generate/listsInput.res.txt | 94 ++--- .../apollo/generate/module_type.res.txt | 8 +- .../apollo/generate/mutationWithArgs.res.txt | 6 +- .../mutationWithArgsAndNoRecords.res.txt | 6 +- .../apollo/generate/nonrecursiveInput.res.txt | 370 +++++++++--------- .../apollo/generate/pokedexScalars.res.txt | 68 ++-- .../apollo/generate/recursiveInput.res.txt | 146 +++---- .../apollo/generate/scalarsArgs.res.txt | 86 ++-- .../apollo/generate/scalarsInput.res.txt | 94 ++--- .../apollo/generate/skipDirectives.res.txt | 6 +- .../native/generate/argNamedQuery.res.txt | 18 +- .../expected/native/generate/comment.res.txt | 184 ++++----- .../native/generate/customScalars.res.txt | 22 +- .../native/generate/customTypes.res.txt | 34 +- .../native/generate/enumInput.res.txt | 22 +- .../generate/fragmentDefinition.res.txt | 20 +- .../native/generate/fragmentUnion.res.txt | 10 +- .../native/generate/hasuraRepro.res.txt | 34 +- .../native/generate/listsArgs.res.txt | 86 ++-- .../native/generate/listsInput.res.txt | 94 ++--- .../native/generate/module_type.res.txt | 8 +- .../native/generate/mutationWithArgs.res.txt | 6 +- .../mutationWithArgsAndNoRecords.res.txt | 6 +- .../native/generate/nonrecursiveInput.res.txt | 370 +++++++++--------- .../native/generate/pokedexScalars.res.txt | 68 ++-- .../native/generate/recursiveInput.res.txt | 146 +++---- .../native/generate/scalarsArgs.res.txt | 86 ++-- .../native/generate/scalarsInput.res.txt | 94 ++--- .../native/generate/skipDirectives.res.txt | 6 +- .../records/generate/argNamedQuery.res.txt | 18 +- .../expected/records/generate/comment.res.txt | 184 ++++----- .../records/generate/customScalars.res.txt | 22 +- .../records/generate/customTypes.res.txt | 34 +- .../records/generate/enumInput.res.txt | 22 +- .../generate/fragmentDefinition.res.txt | 20 +- .../records/generate/fragmentUnion.res.txt | 10 +- .../records/generate/hasuraRepro.res.txt | 34 +- .../records/generate/listsArgs.res.txt | 86 ++-- .../records/generate/listsInput.res.txt | 94 ++--- .../records/generate/module_type.res.txt | 8 +- .../records/generate/mutationWithArgs.res.txt | 6 +- .../mutationWithArgsAndNoRecords.res.txt | 6 +- .../generate/nonrecursiveInput.res.txt | 370 +++++++++--------- .../records/generate/pokedexScalars.res.txt | 68 ++-- .../records/generate/recursiveInput.res.txt | 146 +++---- .../records/generate/scalarsArgs.res.txt | 86 ++-- .../records/generate/scalarsInput.res.txt | 94 ++--- .../records/generate/skipDirectives.res.txt | 6 +- .../template/generate/argNamedQuery.res.txt | 18 +- .../template/generate/comment.res.txt | 184 ++++----- .../template/generate/customScalars.res.txt | 22 +- .../template/generate/customTypes.res.txt | 34 +- .../template/generate/enumInput.res.txt | 22 +- .../generate/fragmentDefinition.res.txt | 20 +- .../template/generate/fragmentUnion.res.txt | 10 +- .../template/generate/hasuraRepro.res.txt | 34 +- .../template/generate/listsArgs.res.txt | 86 ++-- .../template/generate/listsInput.res.txt | 94 ++--- .../template/generate/module_type.res.txt | 8 +- .../generate/mutationWithArgs.res.txt | 6 +- .../mutationWithArgsAndNoRecords.res.txt | 6 +- .../generate/nonrecursiveInput.res.txt | 370 +++++++++--------- .../template/generate/pokedexScalars.res.txt | 68 ++-- .../template/generate/recursiveInput.res.txt | 146 +++---- .../template/generate/scalarsArgs.res.txt | 86 ++-- .../template/generate/scalarsInput.res.txt | 94 ++--- .../template/generate/skipDirectives.res.txt | 6 +- .../uncurried/generate/argNamedQuery.res.txt | 18 +- .../uncurried/generate/comment.res.txt | 184 ++++----- .../uncurried/generate/customScalars.res.txt | 22 +- .../uncurried/generate/customTypes.res.txt | 34 +- .../uncurried/generate/enumInput.res.txt | 22 +- .../generate/fragmentDefinition.res.txt | 20 +- .../uncurried/generate/fragmentUnion.res.txt | 10 +- .../uncurried/generate/hasuraRepro.res.txt | 34 +- .../uncurried/generate/listsArgs.res.txt | 86 ++-- .../uncurried/generate/listsInput.res.txt | 94 ++--- .../uncurried/generate/module_type.res.txt | 8 +- .../generate/mutationWithArgs.res.txt | 6 +- .../mutationWithArgsAndNoRecords.res.txt | 6 +- .../generate/nonrecursiveInput.res.txt | 370 +++++++++--------- .../uncurried/generate/pokedexScalars.res.txt | 68 ++-- .../uncurried/generate/recursiveInput.res.txt | 146 +++---- .../uncurried/generate/scalarsArgs.res.txt | 86 ++-- .../uncurried/generate/scalarsInput.res.txt | 94 ++--- .../uncurried/generate/skipDirectives.res.txt | 6 +- 95 files changed, 3440 insertions(+), 3130 deletions(-) diff --git a/snapshot_tests/operations/expected/apollo/generate/argNamedQuery.res.txt b/snapshot_tests/operations/expected/apollo/generate/argNamedQuery.res.txt index c07a22af..83eba606 100644 --- a/snapshot_tests/operations/expected/apollo/generate/argNamedQuery.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/argNamedQuery.res.txt @@ -42,9 +42,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" @@ -95,9 +95,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" @@ -147,9 +147,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/apollo/generate/comment.res.txt b/snapshot_tests/operations/expected/apollo/generate/comment.res.txt index 7dbfd4a9..2b6fe4cc 100644 --- a/snapshot_tests/operations/expected/apollo/generate/comment.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/comment.res.txt @@ -90,95 +90,101 @@ nonrecursiveInput(arg: $arg) } {nonrecursiveInput: nonrecursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, diff --git a/snapshot_tests/operations/expected/apollo/generate/customScalars.res.txt b/snapshot_tests/operations/expected/apollo/generate/customScalars.res.txt index ba9fd1a2..499ecb71 100644 --- a/snapshot_tests/operations/expected/apollo/generate/customScalars.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/customScalars.res.txt @@ -88,16 +88,18 @@ nonNullable } {customScalarField: customScalarField} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - opt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).opt), - req: (a => a)((inp: t_variables).req), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + opt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).opt), + req: (a => a)((inp: t_variables).req), + }: t_variables => Raw.t_variables + ) let makeVariables = (~opt=?, ~req, ()): t_variables => {opt, req} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/apollo/generate/customTypes.res.txt b/snapshot_tests/operations/expected/apollo/generate/customTypes.res.txt index 203e7fa9..dadbc3a7 100644 --- a/snapshot_tests/operations/expected/apollo/generate/customTypes.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/customTypes.res.txt @@ -25,21 +25,25 @@ module NullableString = { | Red | Green | Blue - let parse: option => t = color => - switch color { - | Some("green") => Green - | Some("blue") => Blue - | Some("red") => Red - | Some(_) - | None => - Red - } - let serialize: t => option = color => - switch color { - | Red => Some("red") - | Green => Some("green") - | Blue => Some("blue") - } + let parse: option => t = ( + color => + switch color { + | Some("green") => Green + | Some("blue") => Blue + | Some("red") => Red + | Some(_) + | None => + Red + }: option => t + ) + let serialize: t => option = ( + color => + switch color { + | Red => Some("red") + | Green => Some("green") + | Blue => Some("blue") + }: t => option + ) } module DateTime = { diff --git a/snapshot_tests/operations/expected/apollo/generate/enumInput.res.txt b/snapshot_tests/operations/expected/apollo/generate/enumInput.res.txt index 2bc9fb0c..5f6ec2df 100644 --- a/snapshot_tests/operations/expected/apollo/generate/enumInput.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/enumInput.res.txt @@ -42,16 +42,18 @@ enumInput(arg: $arg) } {enumInput: enumInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - arg: ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )((inp: t_variables).arg), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/apollo/generate/fragmentDefinition.res.txt b/snapshot_tests/operations/expected/apollo/generate/fragmentDefinition.res.txt index 2f312234..28334959 100644 --- a/snapshot_tests/operations/expected/apollo/generate/fragmentDefinition.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/fragmentDefinition.res.txt @@ -709,15 +709,17 @@ l5: lists { } {l1, l2, l3, l4, l5} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - arg1: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).arg1), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg1: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).arg1), + }: t_variables => Raw.t_variables + ) let makeVariables = (~arg1=?, ()): t_variables => {arg1: arg1} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/apollo/generate/fragmentUnion.res.txt b/snapshot_tests/operations/expected/apollo/generate/fragmentUnion.res.txt index 237333b3..e8057703 100644 --- a/snapshot_tests/operations/expected/apollo/generate/fragmentUnion.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/fragmentUnion.res.txt @@ -1,9 +1,11 @@ module Graphql_ppx_runtime = { // mock - let assign_typename: ( - Js.Json.t, - string, - ) => Js.Json.t = %raw(` (obj, typename) => { obj.__typename = typename; return obj } `) + let assign_typename: (Js.Json.t, string) => Js.Json.t = ( + %raw(` (obj, typename) => { obj.__typename = typename; return obj } `): ( + Js.Json.t, + string, + ) => Js.Json.t + ) } module DogFragment: { @@ocaml.warning("-32-30") diff --git a/snapshot_tests/operations/expected/apollo/generate/hasuraRepro.res.txt b/snapshot_tests/operations/expected/apollo/generate/hasuraRepro.res.txt index 9602645c..3ac6e8c0 100644 --- a/snapshot_tests/operations/expected/apollo/generate/hasuraRepro.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/hasuraRepro.res.txt @@ -118,22 +118,24 @@ hasuraRepro(orderBy: [{id: desc}], block: {number: $blockNumber, type: $type}) } {hasuraRepro: hasuraRepro} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - blockNumber: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).blockNumber), - type_: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).type_), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + blockNumber: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).blockNumber), + type_: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).type_), + }: t_variables => Raw.t_variables + ) let makeVariables = (~blockNumber=?, ~type_=?, ()): t_variables => {blockNumber, type_} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/apollo/generate/listsArgs.res.txt b/snapshot_tests/operations/expected/apollo/generate/listsArgs.res.txt index 9ab32d63..cfb86b9f 100644 --- a/snapshot_tests/operations/expected/apollo/generate/listsArgs.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/listsArgs.res.txt @@ -68,51 +68,53 @@ listsInput(arg: {nullableOfNullable: $nullableOfNullable, nullableOfNonNullable: } {listsInput: listsInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - nullableOfNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + nullableOfNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables).nullableOfNullable), + nullableOfNonNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) + } + )((inp: t_variables).nullableOfNonNullable), + nonNullableOfNullable: ( + a => + Js.Array2.map(a, b => ( a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) ) - } - )((inp: t_variables).nullableOfNullable), - nullableOfNonNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) - } - )((inp: t_variables).nullableOfNonNullable), - nonNullableOfNullable: ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )((inp: t_variables).nonNullableOfNullable), - nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( - (inp: t_variables).nonNullableOfNonNullable, - ), - } + )((inp: t_variables).nonNullableOfNullable), + nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( + (inp: t_variables).nonNullableOfNonNullable, + ), + }: t_variables => Raw.t_variables + ) let makeVariables = ( ~nullableOfNullable=?, ~nullableOfNonNullable=?, diff --git a/snapshot_tests/operations/expected/apollo/generate/listsInput.res.txt b/snapshot_tests/operations/expected/apollo/generate/listsInput.res.txt index c2be8b1b..97a87c50 100644 --- a/snapshot_tests/operations/expected/apollo/generate/listsInput.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/listsInput.res.txt @@ -74,54 +74,58 @@ listsInput(arg: $arg) } {listsInput: listsInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectListsInput(a))((inp: t_variables).arg), - } - and serializeInputObjectListsInput: t_variables_ListsInput => Raw.t_variables_ListsInput = inp => { - nullableOfNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectListsInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectListsInput: t_variables_ListsInput => Raw.t_variables_ListsInput = ( + inp => { + nullableOfNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_ListsInput).nullableOfNullable), + nullableOfNonNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) + } + )((inp: t_variables_ListsInput).nullableOfNonNullable), + nonNullableOfNullable: ( + a => + Js.Array2.map(a, b => ( a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) ) - } - )((inp: t_variables_ListsInput).nullableOfNullable), - nullableOfNonNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) - } - )((inp: t_variables_ListsInput).nullableOfNonNullable), - nonNullableOfNullable: ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )((inp: t_variables_ListsInput).nonNullableOfNullable), - nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( - (inp: t_variables_ListsInput).nonNullableOfNonNullable, - ), - } + )((inp: t_variables_ListsInput).nonNullableOfNullable), + nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( + (inp: t_variables_ListsInput).nonNullableOfNonNullable, + ), + }: t_variables_ListsInput => Raw.t_variables_ListsInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectListsInput = ( ~nullableOfNullable=?, diff --git a/snapshot_tests/operations/expected/apollo/generate/module_type.res.txt b/snapshot_tests/operations/expected/apollo/generate/module_type.res.txt index 7319e711..173b8c3a 100644 --- a/snapshot_tests/operations/expected/apollo/generate/module_type.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/module_type.res.txt @@ -263,8 +263,10 @@ and VariousScalars: { let parse = (nestedObject: MyQueryRecursive.t_nestedObject) => { otherInner: nestedObject.inner, } - let serialize: t => MyQueryRecursive.t_nestedObject = t => { - inner: t.otherInner, - } + let serialize: t => MyQueryRecursive.t_nestedObject = ( + t => { + inner: t.otherInner, + }: t => MyQueryRecursive.t_nestedObject + ) } diff --git a/snapshot_tests/operations/expected/apollo/generate/mutationWithArgs.res.txt b/snapshot_tests/operations/expected/apollo/generate/mutationWithArgs.res.txt index f43ea9e5..12a00d0a 100644 --- a/snapshot_tests/operations/expected/apollo/generate/mutationWithArgs.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/mutationWithArgs.res.txt @@ -42,9 +42,9 @@ optionalInputArgs(required: $required, anotherRequired: "val") } {optionalInputArgs: optionalInputArgs} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - required: (a => a)((inp: t_variables).required), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {required: (a => a)((inp: t_variables).required)}: t_variables => Raw.t_variables + ) let makeVariables = (~required, ()): t_variables => {required: required} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/apollo/generate/mutationWithArgsAndNoRecords.res.txt b/snapshot_tests/operations/expected/apollo/generate/mutationWithArgsAndNoRecords.res.txt index f43ea9e5..12a00d0a 100644 --- a/snapshot_tests/operations/expected/apollo/generate/mutationWithArgsAndNoRecords.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/mutationWithArgsAndNoRecords.res.txt @@ -42,9 +42,9 @@ optionalInputArgs(required: $required, anotherRequired: "val") } {optionalInputArgs: optionalInputArgs} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - required: (a => a)((inp: t_variables).required), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {required: (a => a)((inp: t_variables).required)}: t_variables => Raw.t_variables + ) let makeVariables = (~required, ()): t_variables => {required: required} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/apollo/generate/nonrecursiveInput.res.txt b/snapshot_tests/operations/expected/apollo/generate/nonrecursiveInput.res.txt index 28321d03..6dff639f 100644 --- a/snapshot_tests/operations/expected/apollo/generate/nonrecursiveInput.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/nonrecursiveInput.res.txt @@ -90,95 +90,101 @@ nonrecursiveInput(arg: $arg) } {nonrecursiveInput: nonrecursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, @@ -315,96 +321,102 @@ more: scalarsInput(arg: $arg2) } {scalarsInput, more} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - arg2: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg2), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + arg2: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg2), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ~arg2, ()): t_variables => {arg, arg2} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, diff --git a/snapshot_tests/operations/expected/apollo/generate/pokedexScalars.res.txt b/snapshot_tests/operations/expected/apollo/generate/pokedexScalars.res.txt index 80eabff2..95d7906b 100644 --- a/snapshot_tests/operations/expected/apollo/generate/pokedexScalars.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/pokedexScalars.res.txt @@ -101,22 +101,24 @@ name } {pokemon: pokemon} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - id: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).id), - name: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).name), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + id: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).id), + name: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).name), + }: t_variables => Raw.t_variables + ) let makeVariables = (~id=?, ~name=?, ()): t_variables => {id, name} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" @@ -226,22 +228,24 @@ name } {pokemon: pokemon} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - id: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).id), - name: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).name), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + id: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).id), + name: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).name), + }: t_variables => Raw.t_variables + ) let makeVariables = (~id=?, ~name=?, ()): t_variables => {id, name} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/apollo/generate/recursiveInput.res.txt b/snapshot_tests/operations/expected/apollo/generate/recursiveInput.res.txt index 61216a2f..11ef8b06 100644 --- a/snapshot_tests/operations/expected/apollo/generate/recursiveInput.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/recursiveInput.res.txt @@ -69,42 +69,46 @@ recursiveInput(arg: $arg) } {recursiveInput: recursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectRecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectRecursiveInput: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput = inp => { - otherField: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_RecursiveInput).otherField), - inner: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectRecursiveInput(a))(b)) - } - )((inp: t_variables_RecursiveInput).inner), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_RecursiveInput).enum), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectRecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectRecursiveInput: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput = ( + inp => { + otherField: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_RecursiveInput).otherField), + inner: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectRecursiveInput(a))(b)) + } + )((inp: t_variables_RecursiveInput).inner), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_RecursiveInput).enum), + }: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectRecursiveInput = ( ~otherField=?, @@ -200,37 +204,45 @@ recursiveRepro(input: $input) } {recursiveRepro: recursiveRepro} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - input: (a => serializeInputObjectproblem_input(a))((inp: t_variables).input), - } - and serializeInputObjectproblem_input: t_variables_problem_input => Raw.t_variables_problem_input = inp => { - the_problem: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) - } - )((inp: t_variables_problem_input).the_problem), - b: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectnested_type(a))(b)) - } - )((inp: t_variables_problem_input).b), - } - and serializeInputObjectthis_will_be_duplicated: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated = inp => { - id: (a => a)((inp: t_variables_this_will_be_duplicated).id), - } - and serializeInputObjectnested_type: t_variables_nested_type => Raw.t_variables_nested_type = inp => { - the_problem: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) - } - )((inp: t_variables_nested_type).the_problem), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + input: (a => serializeInputObjectproblem_input(a))((inp: t_variables).input), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectproblem_input: t_variables_problem_input => Raw.t_variables_problem_input = ( + inp => { + the_problem: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) + } + )((inp: t_variables_problem_input).the_problem), + b: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectnested_type(a))(b)) + } + )((inp: t_variables_problem_input).b), + }: t_variables_problem_input => Raw.t_variables_problem_input + ) + and serializeInputObjectthis_will_be_duplicated: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated = ( + inp => { + id: (a => a)((inp: t_variables_this_will_be_duplicated).id), + }: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated + ) + and serializeInputObjectnested_type: t_variables_nested_type => Raw.t_variables_nested_type = ( + inp => { + the_problem: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) + } + )((inp: t_variables_nested_type).the_problem), + }: t_variables_nested_type => Raw.t_variables_nested_type + ) let makeVariables = (~input, ()): t_variables => {input: input} and makeInputObjectproblem_input = (~the_problem=?, ~b=?, ()): t_variables_problem_input => { the_problem, diff --git a/snapshot_tests/operations/expected/apollo/generate/scalarsArgs.res.txt b/snapshot_tests/operations/expected/apollo/generate/scalarsArgs.res.txt index 97ccd80e..6ea92db9 100644 --- a/snapshot_tests/operations/expected/apollo/generate/scalarsArgs.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/scalarsArgs.res.txt @@ -98,48 +98,50 @@ scalarsInput(arg: {nullableString: $nullableString, string: $string, nullableInt } {scalarsInput: scalarsInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - nullableString: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableString), - string: (a => a)((inp: t_variables).string), - nullableInt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableInt), - int: (a => a)((inp: t_variables).int), - nullableFloat: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableFloat), - float: (a => a)((inp: t_variables).float), - nullableBoolean: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableBoolean), - boolean: (a => a)((inp: t_variables).boolean), - nullableID: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableID), - id: (a => a)((inp: t_variables).id), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + nullableString: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableString), + string: (a => a)((inp: t_variables).string), + nullableInt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableInt), + int: (a => a)((inp: t_variables).int), + nullableFloat: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableFloat), + float: (a => a)((inp: t_variables).float), + nullableBoolean: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableBoolean), + boolean: (a => a)((inp: t_variables).boolean), + nullableID: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableID), + id: (a => a)((inp: t_variables).id), + }: t_variables => Raw.t_variables + ) let makeVariables = ( ~nullableString=?, ~string, diff --git a/snapshot_tests/operations/expected/apollo/generate/scalarsInput.res.txt b/snapshot_tests/operations/expected/apollo/generate/scalarsInput.res.txt index 513766f9..60a634ea 100644 --- a/snapshot_tests/operations/expected/apollo/generate/scalarsInput.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/scalarsInput.res.txt @@ -104,51 +104,55 @@ scalarsInput(arg: $arg) } {scalarsInput: scalarsInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectVariousScalarsInput(a))((inp: t_variables).arg), - } - and serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput = inp => { - nullableString: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableString), - string: (a => a)((inp: t_variables_VariousScalarsInput).string), - nullableInt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableInt), - int: (a => a)((inp: t_variables_VariousScalarsInput).int), - nullableFloat: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableFloat), - float: (a => a)((inp: t_variables_VariousScalarsInput).float), - nullableBoolean: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableBoolean), - boolean: (a => a)((inp: t_variables_VariousScalarsInput).boolean), - nullableID: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableID), - id: (a => a)((inp: t_variables_VariousScalarsInput).id), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectVariousScalarsInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput = ( + inp => { + nullableString: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableString), + string: (a => a)((inp: t_variables_VariousScalarsInput).string), + nullableInt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableInt), + int: (a => a)((inp: t_variables_VariousScalarsInput).int), + nullableFloat: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableFloat), + float: (a => a)((inp: t_variables_VariousScalarsInput).float), + nullableBoolean: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableBoolean), + boolean: (a => a)((inp: t_variables_VariousScalarsInput).boolean), + nullableID: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableID), + id: (a => a)((inp: t_variables_VariousScalarsInput).id), + }: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectVariousScalarsInput = ( ~nullableString=?, diff --git a/snapshot_tests/operations/expected/apollo/generate/skipDirectives.res.txt b/snapshot_tests/operations/expected/apollo/generate/skipDirectives.res.txt index 2e6b6c16..317bc5e8 100644 --- a/snapshot_tests/operations/expected/apollo/generate/skipDirectives.res.txt +++ b/snapshot_tests/operations/expected/apollo/generate/skipDirectives.res.txt @@ -164,9 +164,9 @@ string @include(if: $var) } {v1, v2} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - var: (a => a)((inp: t_variables).var), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {var: (a => a)((inp: t_variables).var)}: t_variables => Raw.t_variables + ) let makeVariables = (~var, ()): t_variables => {var: var} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/native/generate/argNamedQuery.res.txt b/snapshot_tests/operations/expected/native/generate/argNamedQuery.res.txt index c07a22af..83eba606 100644 --- a/snapshot_tests/operations/expected/native/generate/argNamedQuery.res.txt +++ b/snapshot_tests/operations/expected/native/generate/argNamedQuery.res.txt @@ -42,9 +42,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" @@ -95,9 +95,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" @@ -147,9 +147,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/native/generate/comment.res.txt b/snapshot_tests/operations/expected/native/generate/comment.res.txt index 7dbfd4a9..2b6fe4cc 100644 --- a/snapshot_tests/operations/expected/native/generate/comment.res.txt +++ b/snapshot_tests/operations/expected/native/generate/comment.res.txt @@ -90,95 +90,101 @@ nonrecursiveInput(arg: $arg) } {nonrecursiveInput: nonrecursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, diff --git a/snapshot_tests/operations/expected/native/generate/customScalars.res.txt b/snapshot_tests/operations/expected/native/generate/customScalars.res.txt index ba9fd1a2..499ecb71 100644 --- a/snapshot_tests/operations/expected/native/generate/customScalars.res.txt +++ b/snapshot_tests/operations/expected/native/generate/customScalars.res.txt @@ -88,16 +88,18 @@ nonNullable } {customScalarField: customScalarField} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - opt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).opt), - req: (a => a)((inp: t_variables).req), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + opt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).opt), + req: (a => a)((inp: t_variables).req), + }: t_variables => Raw.t_variables + ) let makeVariables = (~opt=?, ~req, ()): t_variables => {opt, req} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/native/generate/customTypes.res.txt b/snapshot_tests/operations/expected/native/generate/customTypes.res.txt index 203e7fa9..dadbc3a7 100644 --- a/snapshot_tests/operations/expected/native/generate/customTypes.res.txt +++ b/snapshot_tests/operations/expected/native/generate/customTypes.res.txt @@ -25,21 +25,25 @@ module NullableString = { | Red | Green | Blue - let parse: option => t = color => - switch color { - | Some("green") => Green - | Some("blue") => Blue - | Some("red") => Red - | Some(_) - | None => - Red - } - let serialize: t => option = color => - switch color { - | Red => Some("red") - | Green => Some("green") - | Blue => Some("blue") - } + let parse: option => t = ( + color => + switch color { + | Some("green") => Green + | Some("blue") => Blue + | Some("red") => Red + | Some(_) + | None => + Red + }: option => t + ) + let serialize: t => option = ( + color => + switch color { + | Red => Some("red") + | Green => Some("green") + | Blue => Some("blue") + }: t => option + ) } module DateTime = { diff --git a/snapshot_tests/operations/expected/native/generate/enumInput.res.txt b/snapshot_tests/operations/expected/native/generate/enumInput.res.txt index 2bc9fb0c..5f6ec2df 100644 --- a/snapshot_tests/operations/expected/native/generate/enumInput.res.txt +++ b/snapshot_tests/operations/expected/native/generate/enumInput.res.txt @@ -42,16 +42,18 @@ enumInput(arg: $arg) } {enumInput: enumInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - arg: ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )((inp: t_variables).arg), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/native/generate/fragmentDefinition.res.txt b/snapshot_tests/operations/expected/native/generate/fragmentDefinition.res.txt index 2f312234..28334959 100644 --- a/snapshot_tests/operations/expected/native/generate/fragmentDefinition.res.txt +++ b/snapshot_tests/operations/expected/native/generate/fragmentDefinition.res.txt @@ -709,15 +709,17 @@ l5: lists { } {l1, l2, l3, l4, l5} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - arg1: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).arg1), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg1: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).arg1), + }: t_variables => Raw.t_variables + ) let makeVariables = (~arg1=?, ()): t_variables => {arg1: arg1} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/native/generate/fragmentUnion.res.txt b/snapshot_tests/operations/expected/native/generate/fragmentUnion.res.txt index 237333b3..e8057703 100644 --- a/snapshot_tests/operations/expected/native/generate/fragmentUnion.res.txt +++ b/snapshot_tests/operations/expected/native/generate/fragmentUnion.res.txt @@ -1,9 +1,11 @@ module Graphql_ppx_runtime = { // mock - let assign_typename: ( - Js.Json.t, - string, - ) => Js.Json.t = %raw(` (obj, typename) => { obj.__typename = typename; return obj } `) + let assign_typename: (Js.Json.t, string) => Js.Json.t = ( + %raw(` (obj, typename) => { obj.__typename = typename; return obj } `): ( + Js.Json.t, + string, + ) => Js.Json.t + ) } module DogFragment: { @@ocaml.warning("-32-30") diff --git a/snapshot_tests/operations/expected/native/generate/hasuraRepro.res.txt b/snapshot_tests/operations/expected/native/generate/hasuraRepro.res.txt index 9602645c..3ac6e8c0 100644 --- a/snapshot_tests/operations/expected/native/generate/hasuraRepro.res.txt +++ b/snapshot_tests/operations/expected/native/generate/hasuraRepro.res.txt @@ -118,22 +118,24 @@ hasuraRepro(orderBy: [{id: desc}], block: {number: $blockNumber, type: $type}) } {hasuraRepro: hasuraRepro} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - blockNumber: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).blockNumber), - type_: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).type_), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + blockNumber: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).blockNumber), + type_: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).type_), + }: t_variables => Raw.t_variables + ) let makeVariables = (~blockNumber=?, ~type_=?, ()): t_variables => {blockNumber, type_} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/native/generate/listsArgs.res.txt b/snapshot_tests/operations/expected/native/generate/listsArgs.res.txt index 9ab32d63..cfb86b9f 100644 --- a/snapshot_tests/operations/expected/native/generate/listsArgs.res.txt +++ b/snapshot_tests/operations/expected/native/generate/listsArgs.res.txt @@ -68,51 +68,53 @@ listsInput(arg: {nullableOfNullable: $nullableOfNullable, nullableOfNonNullable: } {listsInput: listsInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - nullableOfNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + nullableOfNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables).nullableOfNullable), + nullableOfNonNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) + } + )((inp: t_variables).nullableOfNonNullable), + nonNullableOfNullable: ( + a => + Js.Array2.map(a, b => ( a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) ) - } - )((inp: t_variables).nullableOfNullable), - nullableOfNonNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) - } - )((inp: t_variables).nullableOfNonNullable), - nonNullableOfNullable: ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )((inp: t_variables).nonNullableOfNullable), - nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( - (inp: t_variables).nonNullableOfNonNullable, - ), - } + )((inp: t_variables).nonNullableOfNullable), + nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( + (inp: t_variables).nonNullableOfNonNullable, + ), + }: t_variables => Raw.t_variables + ) let makeVariables = ( ~nullableOfNullable=?, ~nullableOfNonNullable=?, diff --git a/snapshot_tests/operations/expected/native/generate/listsInput.res.txt b/snapshot_tests/operations/expected/native/generate/listsInput.res.txt index c2be8b1b..97a87c50 100644 --- a/snapshot_tests/operations/expected/native/generate/listsInput.res.txt +++ b/snapshot_tests/operations/expected/native/generate/listsInput.res.txt @@ -74,54 +74,58 @@ listsInput(arg: $arg) } {listsInput: listsInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectListsInput(a))((inp: t_variables).arg), - } - and serializeInputObjectListsInput: t_variables_ListsInput => Raw.t_variables_ListsInput = inp => { - nullableOfNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectListsInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectListsInput: t_variables_ListsInput => Raw.t_variables_ListsInput = ( + inp => { + nullableOfNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_ListsInput).nullableOfNullable), + nullableOfNonNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) + } + )((inp: t_variables_ListsInput).nullableOfNonNullable), + nonNullableOfNullable: ( + a => + Js.Array2.map(a, b => ( a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) ) - } - )((inp: t_variables_ListsInput).nullableOfNullable), - nullableOfNonNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) - } - )((inp: t_variables_ListsInput).nullableOfNonNullable), - nonNullableOfNullable: ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )((inp: t_variables_ListsInput).nonNullableOfNullable), - nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( - (inp: t_variables_ListsInput).nonNullableOfNonNullable, - ), - } + )((inp: t_variables_ListsInput).nonNullableOfNullable), + nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( + (inp: t_variables_ListsInput).nonNullableOfNonNullable, + ), + }: t_variables_ListsInput => Raw.t_variables_ListsInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectListsInput = ( ~nullableOfNullable=?, diff --git a/snapshot_tests/operations/expected/native/generate/module_type.res.txt b/snapshot_tests/operations/expected/native/generate/module_type.res.txt index 7319e711..173b8c3a 100644 --- a/snapshot_tests/operations/expected/native/generate/module_type.res.txt +++ b/snapshot_tests/operations/expected/native/generate/module_type.res.txt @@ -263,8 +263,10 @@ and VariousScalars: { let parse = (nestedObject: MyQueryRecursive.t_nestedObject) => { otherInner: nestedObject.inner, } - let serialize: t => MyQueryRecursive.t_nestedObject = t => { - inner: t.otherInner, - } + let serialize: t => MyQueryRecursive.t_nestedObject = ( + t => { + inner: t.otherInner, + }: t => MyQueryRecursive.t_nestedObject + ) } diff --git a/snapshot_tests/operations/expected/native/generate/mutationWithArgs.res.txt b/snapshot_tests/operations/expected/native/generate/mutationWithArgs.res.txt index f43ea9e5..12a00d0a 100644 --- a/snapshot_tests/operations/expected/native/generate/mutationWithArgs.res.txt +++ b/snapshot_tests/operations/expected/native/generate/mutationWithArgs.res.txt @@ -42,9 +42,9 @@ optionalInputArgs(required: $required, anotherRequired: "val") } {optionalInputArgs: optionalInputArgs} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - required: (a => a)((inp: t_variables).required), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {required: (a => a)((inp: t_variables).required)}: t_variables => Raw.t_variables + ) let makeVariables = (~required, ()): t_variables => {required: required} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/native/generate/mutationWithArgsAndNoRecords.res.txt b/snapshot_tests/operations/expected/native/generate/mutationWithArgsAndNoRecords.res.txt index f43ea9e5..12a00d0a 100644 --- a/snapshot_tests/operations/expected/native/generate/mutationWithArgsAndNoRecords.res.txt +++ b/snapshot_tests/operations/expected/native/generate/mutationWithArgsAndNoRecords.res.txt @@ -42,9 +42,9 @@ optionalInputArgs(required: $required, anotherRequired: "val") } {optionalInputArgs: optionalInputArgs} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - required: (a => a)((inp: t_variables).required), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {required: (a => a)((inp: t_variables).required)}: t_variables => Raw.t_variables + ) let makeVariables = (~required, ()): t_variables => {required: required} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/native/generate/nonrecursiveInput.res.txt b/snapshot_tests/operations/expected/native/generate/nonrecursiveInput.res.txt index 28321d03..6dff639f 100644 --- a/snapshot_tests/operations/expected/native/generate/nonrecursiveInput.res.txt +++ b/snapshot_tests/operations/expected/native/generate/nonrecursiveInput.res.txt @@ -90,95 +90,101 @@ nonrecursiveInput(arg: $arg) } {nonrecursiveInput: nonrecursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, @@ -315,96 +321,102 @@ more: scalarsInput(arg: $arg2) } {scalarsInput, more} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - arg2: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg2), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + arg2: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg2), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ~arg2, ()): t_variables => {arg, arg2} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, diff --git a/snapshot_tests/operations/expected/native/generate/pokedexScalars.res.txt b/snapshot_tests/operations/expected/native/generate/pokedexScalars.res.txt index 80eabff2..95d7906b 100644 --- a/snapshot_tests/operations/expected/native/generate/pokedexScalars.res.txt +++ b/snapshot_tests/operations/expected/native/generate/pokedexScalars.res.txt @@ -101,22 +101,24 @@ name } {pokemon: pokemon} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - id: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).id), - name: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).name), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + id: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).id), + name: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).name), + }: t_variables => Raw.t_variables + ) let makeVariables = (~id=?, ~name=?, ()): t_variables => {id, name} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" @@ -226,22 +228,24 @@ name } {pokemon: pokemon} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - id: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).id), - name: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).name), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + id: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).id), + name: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).name), + }: t_variables => Raw.t_variables + ) let makeVariables = (~id=?, ~name=?, ()): t_variables => {id, name} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/native/generate/recursiveInput.res.txt b/snapshot_tests/operations/expected/native/generate/recursiveInput.res.txt index 61216a2f..11ef8b06 100644 --- a/snapshot_tests/operations/expected/native/generate/recursiveInput.res.txt +++ b/snapshot_tests/operations/expected/native/generate/recursiveInput.res.txt @@ -69,42 +69,46 @@ recursiveInput(arg: $arg) } {recursiveInput: recursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectRecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectRecursiveInput: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput = inp => { - otherField: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_RecursiveInput).otherField), - inner: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectRecursiveInput(a))(b)) - } - )((inp: t_variables_RecursiveInput).inner), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_RecursiveInput).enum), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectRecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectRecursiveInput: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput = ( + inp => { + otherField: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_RecursiveInput).otherField), + inner: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectRecursiveInput(a))(b)) + } + )((inp: t_variables_RecursiveInput).inner), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_RecursiveInput).enum), + }: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectRecursiveInput = ( ~otherField=?, @@ -200,37 +204,45 @@ recursiveRepro(input: $input) } {recursiveRepro: recursiveRepro} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - input: (a => serializeInputObjectproblem_input(a))((inp: t_variables).input), - } - and serializeInputObjectproblem_input: t_variables_problem_input => Raw.t_variables_problem_input = inp => { - the_problem: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) - } - )((inp: t_variables_problem_input).the_problem), - b: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectnested_type(a))(b)) - } - )((inp: t_variables_problem_input).b), - } - and serializeInputObjectthis_will_be_duplicated: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated = inp => { - id: (a => a)((inp: t_variables_this_will_be_duplicated).id), - } - and serializeInputObjectnested_type: t_variables_nested_type => Raw.t_variables_nested_type = inp => { - the_problem: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) - } - )((inp: t_variables_nested_type).the_problem), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + input: (a => serializeInputObjectproblem_input(a))((inp: t_variables).input), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectproblem_input: t_variables_problem_input => Raw.t_variables_problem_input = ( + inp => { + the_problem: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) + } + )((inp: t_variables_problem_input).the_problem), + b: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectnested_type(a))(b)) + } + )((inp: t_variables_problem_input).b), + }: t_variables_problem_input => Raw.t_variables_problem_input + ) + and serializeInputObjectthis_will_be_duplicated: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated = ( + inp => { + id: (a => a)((inp: t_variables_this_will_be_duplicated).id), + }: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated + ) + and serializeInputObjectnested_type: t_variables_nested_type => Raw.t_variables_nested_type = ( + inp => { + the_problem: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) + } + )((inp: t_variables_nested_type).the_problem), + }: t_variables_nested_type => Raw.t_variables_nested_type + ) let makeVariables = (~input, ()): t_variables => {input: input} and makeInputObjectproblem_input = (~the_problem=?, ~b=?, ()): t_variables_problem_input => { the_problem, diff --git a/snapshot_tests/operations/expected/native/generate/scalarsArgs.res.txt b/snapshot_tests/operations/expected/native/generate/scalarsArgs.res.txt index 97ccd80e..6ea92db9 100644 --- a/snapshot_tests/operations/expected/native/generate/scalarsArgs.res.txt +++ b/snapshot_tests/operations/expected/native/generate/scalarsArgs.res.txt @@ -98,48 +98,50 @@ scalarsInput(arg: {nullableString: $nullableString, string: $string, nullableInt } {scalarsInput: scalarsInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - nullableString: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableString), - string: (a => a)((inp: t_variables).string), - nullableInt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableInt), - int: (a => a)((inp: t_variables).int), - nullableFloat: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableFloat), - float: (a => a)((inp: t_variables).float), - nullableBoolean: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableBoolean), - boolean: (a => a)((inp: t_variables).boolean), - nullableID: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableID), - id: (a => a)((inp: t_variables).id), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + nullableString: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableString), + string: (a => a)((inp: t_variables).string), + nullableInt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableInt), + int: (a => a)((inp: t_variables).int), + nullableFloat: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableFloat), + float: (a => a)((inp: t_variables).float), + nullableBoolean: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableBoolean), + boolean: (a => a)((inp: t_variables).boolean), + nullableID: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableID), + id: (a => a)((inp: t_variables).id), + }: t_variables => Raw.t_variables + ) let makeVariables = ( ~nullableString=?, ~string, diff --git a/snapshot_tests/operations/expected/native/generate/scalarsInput.res.txt b/snapshot_tests/operations/expected/native/generate/scalarsInput.res.txt index 513766f9..60a634ea 100644 --- a/snapshot_tests/operations/expected/native/generate/scalarsInput.res.txt +++ b/snapshot_tests/operations/expected/native/generate/scalarsInput.res.txt @@ -104,51 +104,55 @@ scalarsInput(arg: $arg) } {scalarsInput: scalarsInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectVariousScalarsInput(a))((inp: t_variables).arg), - } - and serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput = inp => { - nullableString: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableString), - string: (a => a)((inp: t_variables_VariousScalarsInput).string), - nullableInt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableInt), - int: (a => a)((inp: t_variables_VariousScalarsInput).int), - nullableFloat: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableFloat), - float: (a => a)((inp: t_variables_VariousScalarsInput).float), - nullableBoolean: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableBoolean), - boolean: (a => a)((inp: t_variables_VariousScalarsInput).boolean), - nullableID: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableID), - id: (a => a)((inp: t_variables_VariousScalarsInput).id), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectVariousScalarsInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput = ( + inp => { + nullableString: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableString), + string: (a => a)((inp: t_variables_VariousScalarsInput).string), + nullableInt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableInt), + int: (a => a)((inp: t_variables_VariousScalarsInput).int), + nullableFloat: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableFloat), + float: (a => a)((inp: t_variables_VariousScalarsInput).float), + nullableBoolean: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableBoolean), + boolean: (a => a)((inp: t_variables_VariousScalarsInput).boolean), + nullableID: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableID), + id: (a => a)((inp: t_variables_VariousScalarsInput).id), + }: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectVariousScalarsInput = ( ~nullableString=?, diff --git a/snapshot_tests/operations/expected/native/generate/skipDirectives.res.txt b/snapshot_tests/operations/expected/native/generate/skipDirectives.res.txt index 2e6b6c16..317bc5e8 100644 --- a/snapshot_tests/operations/expected/native/generate/skipDirectives.res.txt +++ b/snapshot_tests/operations/expected/native/generate/skipDirectives.res.txt @@ -164,9 +164,9 @@ string @include(if: $var) } {v1, v2} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - var: (a => a)((inp: t_variables).var), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {var: (a => a)((inp: t_variables).var)}: t_variables => Raw.t_variables + ) let makeVariables = (~var, ()): t_variables => {var: var} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/records/generate/argNamedQuery.res.txt b/snapshot_tests/operations/expected/records/generate/argNamedQuery.res.txt index c07a22af..83eba606 100644 --- a/snapshot_tests/operations/expected/records/generate/argNamedQuery.res.txt +++ b/snapshot_tests/operations/expected/records/generate/argNamedQuery.res.txt @@ -42,9 +42,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" @@ -95,9 +95,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" @@ -147,9 +147,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/records/generate/comment.res.txt b/snapshot_tests/operations/expected/records/generate/comment.res.txt index 7dbfd4a9..2b6fe4cc 100644 --- a/snapshot_tests/operations/expected/records/generate/comment.res.txt +++ b/snapshot_tests/operations/expected/records/generate/comment.res.txt @@ -90,95 +90,101 @@ nonrecursiveInput(arg: $arg) } {nonrecursiveInput: nonrecursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, diff --git a/snapshot_tests/operations/expected/records/generate/customScalars.res.txt b/snapshot_tests/operations/expected/records/generate/customScalars.res.txt index ba9fd1a2..499ecb71 100644 --- a/snapshot_tests/operations/expected/records/generate/customScalars.res.txt +++ b/snapshot_tests/operations/expected/records/generate/customScalars.res.txt @@ -88,16 +88,18 @@ nonNullable } {customScalarField: customScalarField} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - opt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).opt), - req: (a => a)((inp: t_variables).req), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + opt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).opt), + req: (a => a)((inp: t_variables).req), + }: t_variables => Raw.t_variables + ) let makeVariables = (~opt=?, ~req, ()): t_variables => {opt, req} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/records/generate/customTypes.res.txt b/snapshot_tests/operations/expected/records/generate/customTypes.res.txt index 203e7fa9..dadbc3a7 100644 --- a/snapshot_tests/operations/expected/records/generate/customTypes.res.txt +++ b/snapshot_tests/operations/expected/records/generate/customTypes.res.txt @@ -25,21 +25,25 @@ module NullableString = { | Red | Green | Blue - let parse: option => t = color => - switch color { - | Some("green") => Green - | Some("blue") => Blue - | Some("red") => Red - | Some(_) - | None => - Red - } - let serialize: t => option = color => - switch color { - | Red => Some("red") - | Green => Some("green") - | Blue => Some("blue") - } + let parse: option => t = ( + color => + switch color { + | Some("green") => Green + | Some("blue") => Blue + | Some("red") => Red + | Some(_) + | None => + Red + }: option => t + ) + let serialize: t => option = ( + color => + switch color { + | Red => Some("red") + | Green => Some("green") + | Blue => Some("blue") + }: t => option + ) } module DateTime = { diff --git a/snapshot_tests/operations/expected/records/generate/enumInput.res.txt b/snapshot_tests/operations/expected/records/generate/enumInput.res.txt index 2bc9fb0c..5f6ec2df 100644 --- a/snapshot_tests/operations/expected/records/generate/enumInput.res.txt +++ b/snapshot_tests/operations/expected/records/generate/enumInput.res.txt @@ -42,16 +42,18 @@ enumInput(arg: $arg) } {enumInput: enumInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - arg: ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )((inp: t_variables).arg), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/records/generate/fragmentDefinition.res.txt b/snapshot_tests/operations/expected/records/generate/fragmentDefinition.res.txt index 2f312234..28334959 100644 --- a/snapshot_tests/operations/expected/records/generate/fragmentDefinition.res.txt +++ b/snapshot_tests/operations/expected/records/generate/fragmentDefinition.res.txt @@ -709,15 +709,17 @@ l5: lists { } {l1, l2, l3, l4, l5} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - arg1: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).arg1), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg1: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).arg1), + }: t_variables => Raw.t_variables + ) let makeVariables = (~arg1=?, ()): t_variables => {arg1: arg1} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/records/generate/fragmentUnion.res.txt b/snapshot_tests/operations/expected/records/generate/fragmentUnion.res.txt index 237333b3..e8057703 100644 --- a/snapshot_tests/operations/expected/records/generate/fragmentUnion.res.txt +++ b/snapshot_tests/operations/expected/records/generate/fragmentUnion.res.txt @@ -1,9 +1,11 @@ module Graphql_ppx_runtime = { // mock - let assign_typename: ( - Js.Json.t, - string, - ) => Js.Json.t = %raw(` (obj, typename) => { obj.__typename = typename; return obj } `) + let assign_typename: (Js.Json.t, string) => Js.Json.t = ( + %raw(` (obj, typename) => { obj.__typename = typename; return obj } `): ( + Js.Json.t, + string, + ) => Js.Json.t + ) } module DogFragment: { @@ocaml.warning("-32-30") diff --git a/snapshot_tests/operations/expected/records/generate/hasuraRepro.res.txt b/snapshot_tests/operations/expected/records/generate/hasuraRepro.res.txt index 9602645c..3ac6e8c0 100644 --- a/snapshot_tests/operations/expected/records/generate/hasuraRepro.res.txt +++ b/snapshot_tests/operations/expected/records/generate/hasuraRepro.res.txt @@ -118,22 +118,24 @@ hasuraRepro(orderBy: [{id: desc}], block: {number: $blockNumber, type: $type}) } {hasuraRepro: hasuraRepro} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - blockNumber: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).blockNumber), - type_: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).type_), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + blockNumber: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).blockNumber), + type_: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).type_), + }: t_variables => Raw.t_variables + ) let makeVariables = (~blockNumber=?, ~type_=?, ()): t_variables => {blockNumber, type_} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/records/generate/listsArgs.res.txt b/snapshot_tests/operations/expected/records/generate/listsArgs.res.txt index 9ab32d63..cfb86b9f 100644 --- a/snapshot_tests/operations/expected/records/generate/listsArgs.res.txt +++ b/snapshot_tests/operations/expected/records/generate/listsArgs.res.txt @@ -68,51 +68,53 @@ listsInput(arg: {nullableOfNullable: $nullableOfNullable, nullableOfNonNullable: } {listsInput: listsInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - nullableOfNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + nullableOfNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables).nullableOfNullable), + nullableOfNonNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) + } + )((inp: t_variables).nullableOfNonNullable), + nonNullableOfNullable: ( + a => + Js.Array2.map(a, b => ( a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) ) - } - )((inp: t_variables).nullableOfNullable), - nullableOfNonNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) - } - )((inp: t_variables).nullableOfNonNullable), - nonNullableOfNullable: ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )((inp: t_variables).nonNullableOfNullable), - nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( - (inp: t_variables).nonNullableOfNonNullable, - ), - } + )((inp: t_variables).nonNullableOfNullable), + nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( + (inp: t_variables).nonNullableOfNonNullable, + ), + }: t_variables => Raw.t_variables + ) let makeVariables = ( ~nullableOfNullable=?, ~nullableOfNonNullable=?, diff --git a/snapshot_tests/operations/expected/records/generate/listsInput.res.txt b/snapshot_tests/operations/expected/records/generate/listsInput.res.txt index c2be8b1b..97a87c50 100644 --- a/snapshot_tests/operations/expected/records/generate/listsInput.res.txt +++ b/snapshot_tests/operations/expected/records/generate/listsInput.res.txt @@ -74,54 +74,58 @@ listsInput(arg: $arg) } {listsInput: listsInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectListsInput(a))((inp: t_variables).arg), - } - and serializeInputObjectListsInput: t_variables_ListsInput => Raw.t_variables_ListsInput = inp => { - nullableOfNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectListsInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectListsInput: t_variables_ListsInput => Raw.t_variables_ListsInput = ( + inp => { + nullableOfNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_ListsInput).nullableOfNullable), + nullableOfNonNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) + } + )((inp: t_variables_ListsInput).nullableOfNonNullable), + nonNullableOfNullable: ( + a => + Js.Array2.map(a, b => ( a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) ) - } - )((inp: t_variables_ListsInput).nullableOfNullable), - nullableOfNonNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) - } - )((inp: t_variables_ListsInput).nullableOfNonNullable), - nonNullableOfNullable: ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )((inp: t_variables_ListsInput).nonNullableOfNullable), - nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( - (inp: t_variables_ListsInput).nonNullableOfNonNullable, - ), - } + )((inp: t_variables_ListsInput).nonNullableOfNullable), + nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( + (inp: t_variables_ListsInput).nonNullableOfNonNullable, + ), + }: t_variables_ListsInput => Raw.t_variables_ListsInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectListsInput = ( ~nullableOfNullable=?, diff --git a/snapshot_tests/operations/expected/records/generate/module_type.res.txt b/snapshot_tests/operations/expected/records/generate/module_type.res.txt index 7319e711..173b8c3a 100644 --- a/snapshot_tests/operations/expected/records/generate/module_type.res.txt +++ b/snapshot_tests/operations/expected/records/generate/module_type.res.txt @@ -263,8 +263,10 @@ and VariousScalars: { let parse = (nestedObject: MyQueryRecursive.t_nestedObject) => { otherInner: nestedObject.inner, } - let serialize: t => MyQueryRecursive.t_nestedObject = t => { - inner: t.otherInner, - } + let serialize: t => MyQueryRecursive.t_nestedObject = ( + t => { + inner: t.otherInner, + }: t => MyQueryRecursive.t_nestedObject + ) } diff --git a/snapshot_tests/operations/expected/records/generate/mutationWithArgs.res.txt b/snapshot_tests/operations/expected/records/generate/mutationWithArgs.res.txt index f43ea9e5..12a00d0a 100644 --- a/snapshot_tests/operations/expected/records/generate/mutationWithArgs.res.txt +++ b/snapshot_tests/operations/expected/records/generate/mutationWithArgs.res.txt @@ -42,9 +42,9 @@ optionalInputArgs(required: $required, anotherRequired: "val") } {optionalInputArgs: optionalInputArgs} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - required: (a => a)((inp: t_variables).required), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {required: (a => a)((inp: t_variables).required)}: t_variables => Raw.t_variables + ) let makeVariables = (~required, ()): t_variables => {required: required} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/records/generate/mutationWithArgsAndNoRecords.res.txt b/snapshot_tests/operations/expected/records/generate/mutationWithArgsAndNoRecords.res.txt index f43ea9e5..12a00d0a 100644 --- a/snapshot_tests/operations/expected/records/generate/mutationWithArgsAndNoRecords.res.txt +++ b/snapshot_tests/operations/expected/records/generate/mutationWithArgsAndNoRecords.res.txt @@ -42,9 +42,9 @@ optionalInputArgs(required: $required, anotherRequired: "val") } {optionalInputArgs: optionalInputArgs} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - required: (a => a)((inp: t_variables).required), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {required: (a => a)((inp: t_variables).required)}: t_variables => Raw.t_variables + ) let makeVariables = (~required, ()): t_variables => {required: required} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/records/generate/nonrecursiveInput.res.txt b/snapshot_tests/operations/expected/records/generate/nonrecursiveInput.res.txt index 28321d03..6dff639f 100644 --- a/snapshot_tests/operations/expected/records/generate/nonrecursiveInput.res.txt +++ b/snapshot_tests/operations/expected/records/generate/nonrecursiveInput.res.txt @@ -90,95 +90,101 @@ nonrecursiveInput(arg: $arg) } {nonrecursiveInput: nonrecursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, @@ -315,96 +321,102 @@ more: scalarsInput(arg: $arg2) } {scalarsInput, more} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - arg2: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg2), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + arg2: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg2), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ~arg2, ()): t_variables => {arg, arg2} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, diff --git a/snapshot_tests/operations/expected/records/generate/pokedexScalars.res.txt b/snapshot_tests/operations/expected/records/generate/pokedexScalars.res.txt index 80eabff2..95d7906b 100644 --- a/snapshot_tests/operations/expected/records/generate/pokedexScalars.res.txt +++ b/snapshot_tests/operations/expected/records/generate/pokedexScalars.res.txt @@ -101,22 +101,24 @@ name } {pokemon: pokemon} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - id: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).id), - name: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).name), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + id: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).id), + name: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).name), + }: t_variables => Raw.t_variables + ) let makeVariables = (~id=?, ~name=?, ()): t_variables => {id, name} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" @@ -226,22 +228,24 @@ name } {pokemon: pokemon} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - id: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).id), - name: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).name), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + id: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).id), + name: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).name), + }: t_variables => Raw.t_variables + ) let makeVariables = (~id=?, ~name=?, ()): t_variables => {id, name} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/records/generate/recursiveInput.res.txt b/snapshot_tests/operations/expected/records/generate/recursiveInput.res.txt index 61216a2f..11ef8b06 100644 --- a/snapshot_tests/operations/expected/records/generate/recursiveInput.res.txt +++ b/snapshot_tests/operations/expected/records/generate/recursiveInput.res.txt @@ -69,42 +69,46 @@ recursiveInput(arg: $arg) } {recursiveInput: recursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectRecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectRecursiveInput: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput = inp => { - otherField: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_RecursiveInput).otherField), - inner: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectRecursiveInput(a))(b)) - } - )((inp: t_variables_RecursiveInput).inner), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_RecursiveInput).enum), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectRecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectRecursiveInput: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput = ( + inp => { + otherField: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_RecursiveInput).otherField), + inner: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectRecursiveInput(a))(b)) + } + )((inp: t_variables_RecursiveInput).inner), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_RecursiveInput).enum), + }: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectRecursiveInput = ( ~otherField=?, @@ -200,37 +204,45 @@ recursiveRepro(input: $input) } {recursiveRepro: recursiveRepro} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - input: (a => serializeInputObjectproblem_input(a))((inp: t_variables).input), - } - and serializeInputObjectproblem_input: t_variables_problem_input => Raw.t_variables_problem_input = inp => { - the_problem: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) - } - )((inp: t_variables_problem_input).the_problem), - b: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectnested_type(a))(b)) - } - )((inp: t_variables_problem_input).b), - } - and serializeInputObjectthis_will_be_duplicated: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated = inp => { - id: (a => a)((inp: t_variables_this_will_be_duplicated).id), - } - and serializeInputObjectnested_type: t_variables_nested_type => Raw.t_variables_nested_type = inp => { - the_problem: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) - } - )((inp: t_variables_nested_type).the_problem), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + input: (a => serializeInputObjectproblem_input(a))((inp: t_variables).input), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectproblem_input: t_variables_problem_input => Raw.t_variables_problem_input = ( + inp => { + the_problem: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) + } + )((inp: t_variables_problem_input).the_problem), + b: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectnested_type(a))(b)) + } + )((inp: t_variables_problem_input).b), + }: t_variables_problem_input => Raw.t_variables_problem_input + ) + and serializeInputObjectthis_will_be_duplicated: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated = ( + inp => { + id: (a => a)((inp: t_variables_this_will_be_duplicated).id), + }: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated + ) + and serializeInputObjectnested_type: t_variables_nested_type => Raw.t_variables_nested_type = ( + inp => { + the_problem: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) + } + )((inp: t_variables_nested_type).the_problem), + }: t_variables_nested_type => Raw.t_variables_nested_type + ) let makeVariables = (~input, ()): t_variables => {input: input} and makeInputObjectproblem_input = (~the_problem=?, ~b=?, ()): t_variables_problem_input => { the_problem, diff --git a/snapshot_tests/operations/expected/records/generate/scalarsArgs.res.txt b/snapshot_tests/operations/expected/records/generate/scalarsArgs.res.txt index 97ccd80e..6ea92db9 100644 --- a/snapshot_tests/operations/expected/records/generate/scalarsArgs.res.txt +++ b/snapshot_tests/operations/expected/records/generate/scalarsArgs.res.txt @@ -98,48 +98,50 @@ scalarsInput(arg: {nullableString: $nullableString, string: $string, nullableInt } {scalarsInput: scalarsInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - nullableString: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableString), - string: (a => a)((inp: t_variables).string), - nullableInt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableInt), - int: (a => a)((inp: t_variables).int), - nullableFloat: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableFloat), - float: (a => a)((inp: t_variables).float), - nullableBoolean: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableBoolean), - boolean: (a => a)((inp: t_variables).boolean), - nullableID: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableID), - id: (a => a)((inp: t_variables).id), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + nullableString: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableString), + string: (a => a)((inp: t_variables).string), + nullableInt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableInt), + int: (a => a)((inp: t_variables).int), + nullableFloat: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableFloat), + float: (a => a)((inp: t_variables).float), + nullableBoolean: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableBoolean), + boolean: (a => a)((inp: t_variables).boolean), + nullableID: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableID), + id: (a => a)((inp: t_variables).id), + }: t_variables => Raw.t_variables + ) let makeVariables = ( ~nullableString=?, ~string, diff --git a/snapshot_tests/operations/expected/records/generate/scalarsInput.res.txt b/snapshot_tests/operations/expected/records/generate/scalarsInput.res.txt index 513766f9..60a634ea 100644 --- a/snapshot_tests/operations/expected/records/generate/scalarsInput.res.txt +++ b/snapshot_tests/operations/expected/records/generate/scalarsInput.res.txt @@ -104,51 +104,55 @@ scalarsInput(arg: $arg) } {scalarsInput: scalarsInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectVariousScalarsInput(a))((inp: t_variables).arg), - } - and serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput = inp => { - nullableString: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableString), - string: (a => a)((inp: t_variables_VariousScalarsInput).string), - nullableInt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableInt), - int: (a => a)((inp: t_variables_VariousScalarsInput).int), - nullableFloat: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableFloat), - float: (a => a)((inp: t_variables_VariousScalarsInput).float), - nullableBoolean: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableBoolean), - boolean: (a => a)((inp: t_variables_VariousScalarsInput).boolean), - nullableID: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableID), - id: (a => a)((inp: t_variables_VariousScalarsInput).id), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectVariousScalarsInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput = ( + inp => { + nullableString: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableString), + string: (a => a)((inp: t_variables_VariousScalarsInput).string), + nullableInt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableInt), + int: (a => a)((inp: t_variables_VariousScalarsInput).int), + nullableFloat: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableFloat), + float: (a => a)((inp: t_variables_VariousScalarsInput).float), + nullableBoolean: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableBoolean), + boolean: (a => a)((inp: t_variables_VariousScalarsInput).boolean), + nullableID: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableID), + id: (a => a)((inp: t_variables_VariousScalarsInput).id), + }: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectVariousScalarsInput = ( ~nullableString=?, diff --git a/snapshot_tests/operations/expected/records/generate/skipDirectives.res.txt b/snapshot_tests/operations/expected/records/generate/skipDirectives.res.txt index 2e6b6c16..317bc5e8 100644 --- a/snapshot_tests/operations/expected/records/generate/skipDirectives.res.txt +++ b/snapshot_tests/operations/expected/records/generate/skipDirectives.res.txt @@ -164,9 +164,9 @@ string @include(if: $var) } {v1, v2} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - var: (a => a)((inp: t_variables).var), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {var: (a => a)((inp: t_variables).var)}: t_variables => Raw.t_variables + ) let makeVariables = (~var, ()): t_variables => {var: var} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/template/generate/argNamedQuery.res.txt b/snapshot_tests/operations/expected/template/generate/argNamedQuery.res.txt index c07a22af..83eba606 100644 --- a/snapshot_tests/operations/expected/template/generate/argNamedQuery.res.txt +++ b/snapshot_tests/operations/expected/template/generate/argNamedQuery.res.txt @@ -42,9 +42,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" @@ -95,9 +95,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" @@ -147,9 +147,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/template/generate/comment.res.txt b/snapshot_tests/operations/expected/template/generate/comment.res.txt index 7dbfd4a9..2b6fe4cc 100644 --- a/snapshot_tests/operations/expected/template/generate/comment.res.txt +++ b/snapshot_tests/operations/expected/template/generate/comment.res.txt @@ -90,95 +90,101 @@ nonrecursiveInput(arg: $arg) } {nonrecursiveInput: nonrecursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, diff --git a/snapshot_tests/operations/expected/template/generate/customScalars.res.txt b/snapshot_tests/operations/expected/template/generate/customScalars.res.txt index ba9fd1a2..499ecb71 100644 --- a/snapshot_tests/operations/expected/template/generate/customScalars.res.txt +++ b/snapshot_tests/operations/expected/template/generate/customScalars.res.txt @@ -88,16 +88,18 @@ nonNullable } {customScalarField: customScalarField} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - opt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).opt), - req: (a => a)((inp: t_variables).req), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + opt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).opt), + req: (a => a)((inp: t_variables).req), + }: t_variables => Raw.t_variables + ) let makeVariables = (~opt=?, ~req, ()): t_variables => {opt, req} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/template/generate/customTypes.res.txt b/snapshot_tests/operations/expected/template/generate/customTypes.res.txt index 203e7fa9..dadbc3a7 100644 --- a/snapshot_tests/operations/expected/template/generate/customTypes.res.txt +++ b/snapshot_tests/operations/expected/template/generate/customTypes.res.txt @@ -25,21 +25,25 @@ module NullableString = { | Red | Green | Blue - let parse: option => t = color => - switch color { - | Some("green") => Green - | Some("blue") => Blue - | Some("red") => Red - | Some(_) - | None => - Red - } - let serialize: t => option = color => - switch color { - | Red => Some("red") - | Green => Some("green") - | Blue => Some("blue") - } + let parse: option => t = ( + color => + switch color { + | Some("green") => Green + | Some("blue") => Blue + | Some("red") => Red + | Some(_) + | None => + Red + }: option => t + ) + let serialize: t => option = ( + color => + switch color { + | Red => Some("red") + | Green => Some("green") + | Blue => Some("blue") + }: t => option + ) } module DateTime = { diff --git a/snapshot_tests/operations/expected/template/generate/enumInput.res.txt b/snapshot_tests/operations/expected/template/generate/enumInput.res.txt index 2bc9fb0c..5f6ec2df 100644 --- a/snapshot_tests/operations/expected/template/generate/enumInput.res.txt +++ b/snapshot_tests/operations/expected/template/generate/enumInput.res.txt @@ -42,16 +42,18 @@ enumInput(arg: $arg) } {enumInput: enumInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - arg: ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )((inp: t_variables).arg), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/template/generate/fragmentDefinition.res.txt b/snapshot_tests/operations/expected/template/generate/fragmentDefinition.res.txt index 2f312234..28334959 100644 --- a/snapshot_tests/operations/expected/template/generate/fragmentDefinition.res.txt +++ b/snapshot_tests/operations/expected/template/generate/fragmentDefinition.res.txt @@ -709,15 +709,17 @@ l5: lists { } {l1, l2, l3, l4, l5} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - arg1: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).arg1), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg1: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).arg1), + }: t_variables => Raw.t_variables + ) let makeVariables = (~arg1=?, ()): t_variables => {arg1: arg1} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/template/generate/fragmentUnion.res.txt b/snapshot_tests/operations/expected/template/generate/fragmentUnion.res.txt index 237333b3..e8057703 100644 --- a/snapshot_tests/operations/expected/template/generate/fragmentUnion.res.txt +++ b/snapshot_tests/operations/expected/template/generate/fragmentUnion.res.txt @@ -1,9 +1,11 @@ module Graphql_ppx_runtime = { // mock - let assign_typename: ( - Js.Json.t, - string, - ) => Js.Json.t = %raw(` (obj, typename) => { obj.__typename = typename; return obj } `) + let assign_typename: (Js.Json.t, string) => Js.Json.t = ( + %raw(` (obj, typename) => { obj.__typename = typename; return obj } `): ( + Js.Json.t, + string, + ) => Js.Json.t + ) } module DogFragment: { @@ocaml.warning("-32-30") diff --git a/snapshot_tests/operations/expected/template/generate/hasuraRepro.res.txt b/snapshot_tests/operations/expected/template/generate/hasuraRepro.res.txt index 9602645c..3ac6e8c0 100644 --- a/snapshot_tests/operations/expected/template/generate/hasuraRepro.res.txt +++ b/snapshot_tests/operations/expected/template/generate/hasuraRepro.res.txt @@ -118,22 +118,24 @@ hasuraRepro(orderBy: [{id: desc}], block: {number: $blockNumber, type: $type}) } {hasuraRepro: hasuraRepro} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - blockNumber: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).blockNumber), - type_: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).type_), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + blockNumber: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).blockNumber), + type_: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).type_), + }: t_variables => Raw.t_variables + ) let makeVariables = (~blockNumber=?, ~type_=?, ()): t_variables => {blockNumber, type_} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/template/generate/listsArgs.res.txt b/snapshot_tests/operations/expected/template/generate/listsArgs.res.txt index 9ab32d63..cfb86b9f 100644 --- a/snapshot_tests/operations/expected/template/generate/listsArgs.res.txt +++ b/snapshot_tests/operations/expected/template/generate/listsArgs.res.txt @@ -68,51 +68,53 @@ listsInput(arg: {nullableOfNullable: $nullableOfNullable, nullableOfNonNullable: } {listsInput: listsInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - nullableOfNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + nullableOfNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables).nullableOfNullable), + nullableOfNonNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) + } + )((inp: t_variables).nullableOfNonNullable), + nonNullableOfNullable: ( + a => + Js.Array2.map(a, b => ( a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) ) - } - )((inp: t_variables).nullableOfNullable), - nullableOfNonNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) - } - )((inp: t_variables).nullableOfNonNullable), - nonNullableOfNullable: ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )((inp: t_variables).nonNullableOfNullable), - nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( - (inp: t_variables).nonNullableOfNonNullable, - ), - } + )((inp: t_variables).nonNullableOfNullable), + nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( + (inp: t_variables).nonNullableOfNonNullable, + ), + }: t_variables => Raw.t_variables + ) let makeVariables = ( ~nullableOfNullable=?, ~nullableOfNonNullable=?, diff --git a/snapshot_tests/operations/expected/template/generate/listsInput.res.txt b/snapshot_tests/operations/expected/template/generate/listsInput.res.txt index c2be8b1b..97a87c50 100644 --- a/snapshot_tests/operations/expected/template/generate/listsInput.res.txt +++ b/snapshot_tests/operations/expected/template/generate/listsInput.res.txt @@ -74,54 +74,58 @@ listsInput(arg: $arg) } {listsInput: listsInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectListsInput(a))((inp: t_variables).arg), - } - and serializeInputObjectListsInput: t_variables_ListsInput => Raw.t_variables_ListsInput = inp => { - nullableOfNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectListsInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectListsInput: t_variables_ListsInput => Raw.t_variables_ListsInput = ( + inp => { + nullableOfNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_ListsInput).nullableOfNullable), + nullableOfNonNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) + } + )((inp: t_variables_ListsInput).nullableOfNonNullable), + nonNullableOfNullable: ( + a => + Js.Array2.map(a, b => ( a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) ) - } - )((inp: t_variables_ListsInput).nullableOfNullable), - nullableOfNonNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) - } - )((inp: t_variables_ListsInput).nullableOfNonNullable), - nonNullableOfNullable: ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )((inp: t_variables_ListsInput).nonNullableOfNullable), - nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( - (inp: t_variables_ListsInput).nonNullableOfNonNullable, - ), - } + )((inp: t_variables_ListsInput).nonNullableOfNullable), + nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( + (inp: t_variables_ListsInput).nonNullableOfNonNullable, + ), + }: t_variables_ListsInput => Raw.t_variables_ListsInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectListsInput = ( ~nullableOfNullable=?, diff --git a/snapshot_tests/operations/expected/template/generate/module_type.res.txt b/snapshot_tests/operations/expected/template/generate/module_type.res.txt index 7319e711..173b8c3a 100644 --- a/snapshot_tests/operations/expected/template/generate/module_type.res.txt +++ b/snapshot_tests/operations/expected/template/generate/module_type.res.txt @@ -263,8 +263,10 @@ and VariousScalars: { let parse = (nestedObject: MyQueryRecursive.t_nestedObject) => { otherInner: nestedObject.inner, } - let serialize: t => MyQueryRecursive.t_nestedObject = t => { - inner: t.otherInner, - } + let serialize: t => MyQueryRecursive.t_nestedObject = ( + t => { + inner: t.otherInner, + }: t => MyQueryRecursive.t_nestedObject + ) } diff --git a/snapshot_tests/operations/expected/template/generate/mutationWithArgs.res.txt b/snapshot_tests/operations/expected/template/generate/mutationWithArgs.res.txt index f43ea9e5..12a00d0a 100644 --- a/snapshot_tests/operations/expected/template/generate/mutationWithArgs.res.txt +++ b/snapshot_tests/operations/expected/template/generate/mutationWithArgs.res.txt @@ -42,9 +42,9 @@ optionalInputArgs(required: $required, anotherRequired: "val") } {optionalInputArgs: optionalInputArgs} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - required: (a => a)((inp: t_variables).required), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {required: (a => a)((inp: t_variables).required)}: t_variables => Raw.t_variables + ) let makeVariables = (~required, ()): t_variables => {required: required} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/template/generate/mutationWithArgsAndNoRecords.res.txt b/snapshot_tests/operations/expected/template/generate/mutationWithArgsAndNoRecords.res.txt index f43ea9e5..12a00d0a 100644 --- a/snapshot_tests/operations/expected/template/generate/mutationWithArgsAndNoRecords.res.txt +++ b/snapshot_tests/operations/expected/template/generate/mutationWithArgsAndNoRecords.res.txt @@ -42,9 +42,9 @@ optionalInputArgs(required: $required, anotherRequired: "val") } {optionalInputArgs: optionalInputArgs} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - required: (a => a)((inp: t_variables).required), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {required: (a => a)((inp: t_variables).required)}: t_variables => Raw.t_variables + ) let makeVariables = (~required, ()): t_variables => {required: required} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/template/generate/nonrecursiveInput.res.txt b/snapshot_tests/operations/expected/template/generate/nonrecursiveInput.res.txt index 28321d03..6dff639f 100644 --- a/snapshot_tests/operations/expected/template/generate/nonrecursiveInput.res.txt +++ b/snapshot_tests/operations/expected/template/generate/nonrecursiveInput.res.txt @@ -90,95 +90,101 @@ nonrecursiveInput(arg: $arg) } {nonrecursiveInput: nonrecursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, @@ -315,96 +321,102 @@ more: scalarsInput(arg: $arg2) } {scalarsInput, more} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - arg2: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg2), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + arg2: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg2), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ~arg2, ()): t_variables => {arg, arg2} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, diff --git a/snapshot_tests/operations/expected/template/generate/pokedexScalars.res.txt b/snapshot_tests/operations/expected/template/generate/pokedexScalars.res.txt index 80eabff2..95d7906b 100644 --- a/snapshot_tests/operations/expected/template/generate/pokedexScalars.res.txt +++ b/snapshot_tests/operations/expected/template/generate/pokedexScalars.res.txt @@ -101,22 +101,24 @@ name } {pokemon: pokemon} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - id: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).id), - name: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).name), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + id: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).id), + name: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).name), + }: t_variables => Raw.t_variables + ) let makeVariables = (~id=?, ~name=?, ()): t_variables => {id, name} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" @@ -226,22 +228,24 @@ name } {pokemon: pokemon} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - id: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).id), - name: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).name), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + id: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).id), + name: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).name), + }: t_variables => Raw.t_variables + ) let makeVariables = (~id=?, ~name=?, ()): t_variables => {id, name} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/template/generate/recursiveInput.res.txt b/snapshot_tests/operations/expected/template/generate/recursiveInput.res.txt index 61216a2f..11ef8b06 100644 --- a/snapshot_tests/operations/expected/template/generate/recursiveInput.res.txt +++ b/snapshot_tests/operations/expected/template/generate/recursiveInput.res.txt @@ -69,42 +69,46 @@ recursiveInput(arg: $arg) } {recursiveInput: recursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectRecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectRecursiveInput: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput = inp => { - otherField: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_RecursiveInput).otherField), - inner: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectRecursiveInput(a))(b)) - } - )((inp: t_variables_RecursiveInput).inner), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_RecursiveInput).enum), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectRecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectRecursiveInput: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput = ( + inp => { + otherField: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_RecursiveInput).otherField), + inner: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectRecursiveInput(a))(b)) + } + )((inp: t_variables_RecursiveInput).inner), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_RecursiveInput).enum), + }: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectRecursiveInput = ( ~otherField=?, @@ -200,37 +204,45 @@ recursiveRepro(input: $input) } {recursiveRepro: recursiveRepro} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - input: (a => serializeInputObjectproblem_input(a))((inp: t_variables).input), - } - and serializeInputObjectproblem_input: t_variables_problem_input => Raw.t_variables_problem_input = inp => { - the_problem: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) - } - )((inp: t_variables_problem_input).the_problem), - b: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectnested_type(a))(b)) - } - )((inp: t_variables_problem_input).b), - } - and serializeInputObjectthis_will_be_duplicated: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated = inp => { - id: (a => a)((inp: t_variables_this_will_be_duplicated).id), - } - and serializeInputObjectnested_type: t_variables_nested_type => Raw.t_variables_nested_type = inp => { - the_problem: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) - } - )((inp: t_variables_nested_type).the_problem), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + input: (a => serializeInputObjectproblem_input(a))((inp: t_variables).input), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectproblem_input: t_variables_problem_input => Raw.t_variables_problem_input = ( + inp => { + the_problem: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) + } + )((inp: t_variables_problem_input).the_problem), + b: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectnested_type(a))(b)) + } + )((inp: t_variables_problem_input).b), + }: t_variables_problem_input => Raw.t_variables_problem_input + ) + and serializeInputObjectthis_will_be_duplicated: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated = ( + inp => { + id: (a => a)((inp: t_variables_this_will_be_duplicated).id), + }: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated + ) + and serializeInputObjectnested_type: t_variables_nested_type => Raw.t_variables_nested_type = ( + inp => { + the_problem: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) + } + )((inp: t_variables_nested_type).the_problem), + }: t_variables_nested_type => Raw.t_variables_nested_type + ) let makeVariables = (~input, ()): t_variables => {input: input} and makeInputObjectproblem_input = (~the_problem=?, ~b=?, ()): t_variables_problem_input => { the_problem, diff --git a/snapshot_tests/operations/expected/template/generate/scalarsArgs.res.txt b/snapshot_tests/operations/expected/template/generate/scalarsArgs.res.txt index 97ccd80e..6ea92db9 100644 --- a/snapshot_tests/operations/expected/template/generate/scalarsArgs.res.txt +++ b/snapshot_tests/operations/expected/template/generate/scalarsArgs.res.txt @@ -98,48 +98,50 @@ scalarsInput(arg: {nullableString: $nullableString, string: $string, nullableInt } {scalarsInput: scalarsInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - nullableString: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableString), - string: (a => a)((inp: t_variables).string), - nullableInt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableInt), - int: (a => a)((inp: t_variables).int), - nullableFloat: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableFloat), - float: (a => a)((inp: t_variables).float), - nullableBoolean: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableBoolean), - boolean: (a => a)((inp: t_variables).boolean), - nullableID: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableID), - id: (a => a)((inp: t_variables).id), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + nullableString: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableString), + string: (a => a)((inp: t_variables).string), + nullableInt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableInt), + int: (a => a)((inp: t_variables).int), + nullableFloat: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableFloat), + float: (a => a)((inp: t_variables).float), + nullableBoolean: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableBoolean), + boolean: (a => a)((inp: t_variables).boolean), + nullableID: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableID), + id: (a => a)((inp: t_variables).id), + }: t_variables => Raw.t_variables + ) let makeVariables = ( ~nullableString=?, ~string, diff --git a/snapshot_tests/operations/expected/template/generate/scalarsInput.res.txt b/snapshot_tests/operations/expected/template/generate/scalarsInput.res.txt index 513766f9..60a634ea 100644 --- a/snapshot_tests/operations/expected/template/generate/scalarsInput.res.txt +++ b/snapshot_tests/operations/expected/template/generate/scalarsInput.res.txt @@ -104,51 +104,55 @@ scalarsInput(arg: $arg) } {scalarsInput: scalarsInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectVariousScalarsInput(a))((inp: t_variables).arg), - } - and serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput = inp => { - nullableString: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableString), - string: (a => a)((inp: t_variables_VariousScalarsInput).string), - nullableInt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableInt), - int: (a => a)((inp: t_variables_VariousScalarsInput).int), - nullableFloat: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableFloat), - float: (a => a)((inp: t_variables_VariousScalarsInput).float), - nullableBoolean: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableBoolean), - boolean: (a => a)((inp: t_variables_VariousScalarsInput).boolean), - nullableID: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableID), - id: (a => a)((inp: t_variables_VariousScalarsInput).id), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectVariousScalarsInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput = ( + inp => { + nullableString: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableString), + string: (a => a)((inp: t_variables_VariousScalarsInput).string), + nullableInt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableInt), + int: (a => a)((inp: t_variables_VariousScalarsInput).int), + nullableFloat: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableFloat), + float: (a => a)((inp: t_variables_VariousScalarsInput).float), + nullableBoolean: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableBoolean), + boolean: (a => a)((inp: t_variables_VariousScalarsInput).boolean), + nullableID: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableID), + id: (a => a)((inp: t_variables_VariousScalarsInput).id), + }: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectVariousScalarsInput = ( ~nullableString=?, diff --git a/snapshot_tests/operations/expected/template/generate/skipDirectives.res.txt b/snapshot_tests/operations/expected/template/generate/skipDirectives.res.txt index 2e6b6c16..317bc5e8 100644 --- a/snapshot_tests/operations/expected/template/generate/skipDirectives.res.txt +++ b/snapshot_tests/operations/expected/template/generate/skipDirectives.res.txt @@ -164,9 +164,9 @@ string @include(if: $var) } {v1, v2} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - var: (a => a)((inp: t_variables).var), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {var: (a => a)((inp: t_variables).var)}: t_variables => Raw.t_variables + ) let makeVariables = (~var, ()): t_variables => {var: var} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/uncurried/generate/argNamedQuery.res.txt b/snapshot_tests/operations/expected/uncurried/generate/argNamedQuery.res.txt index c07a22af..83eba606 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/argNamedQuery.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/argNamedQuery.res.txt @@ -42,9 +42,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" @@ -95,9 +95,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" @@ -147,9 +147,9 @@ argNamedQuery(query: $query) } {argNamedQuery: argNamedQuery} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - query: (a => a)((inp: t_variables).query), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {query: (a => a)((inp: t_variables).query)}: t_variables => Raw.t_variables + ) let makeVariables = (~query, ()): t_variables => {query: query} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/uncurried/generate/comment.res.txt b/snapshot_tests/operations/expected/uncurried/generate/comment.res.txt index 7dbfd4a9..2b6fe4cc 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/comment.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/comment.res.txt @@ -90,95 +90,101 @@ nonrecursiveInput(arg: $arg) } {nonrecursiveInput: nonrecursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, diff --git a/snapshot_tests/operations/expected/uncurried/generate/customScalars.res.txt b/snapshot_tests/operations/expected/uncurried/generate/customScalars.res.txt index ba9fd1a2..499ecb71 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/customScalars.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/customScalars.res.txt @@ -88,16 +88,18 @@ nonNullable } {customScalarField: customScalarField} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - opt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).opt), - req: (a => a)((inp: t_variables).req), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + opt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).opt), + req: (a => a)((inp: t_variables).req), + }: t_variables => Raw.t_variables + ) let makeVariables = (~opt=?, ~req, ()): t_variables => {opt, req} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/uncurried/generate/customTypes.res.txt b/snapshot_tests/operations/expected/uncurried/generate/customTypes.res.txt index 203e7fa9..dadbc3a7 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/customTypes.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/customTypes.res.txt @@ -25,21 +25,25 @@ module NullableString = { | Red | Green | Blue - let parse: option => t = color => - switch color { - | Some("green") => Green - | Some("blue") => Blue - | Some("red") => Red - | Some(_) - | None => - Red - } - let serialize: t => option = color => - switch color { - | Red => Some("red") - | Green => Some("green") - | Blue => Some("blue") - } + let parse: option => t = ( + color => + switch color { + | Some("green") => Green + | Some("blue") => Blue + | Some("red") => Red + | Some(_) + | None => + Red + }: option => t + ) + let serialize: t => option = ( + color => + switch color { + | Red => Some("red") + | Green => Some("green") + | Blue => Some("blue") + }: t => option + ) } module DateTime = { diff --git a/snapshot_tests/operations/expected/uncurried/generate/enumInput.res.txt b/snapshot_tests/operations/expected/uncurried/generate/enumInput.res.txt index 2bc9fb0c..5f6ec2df 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/enumInput.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/enumInput.res.txt @@ -42,16 +42,18 @@ enumInput(arg: $arg) } {enumInput: enumInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - arg: ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )((inp: t_variables).arg), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/uncurried/generate/fragmentDefinition.res.txt b/snapshot_tests/operations/expected/uncurried/generate/fragmentDefinition.res.txt index 2f312234..28334959 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/fragmentDefinition.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/fragmentDefinition.res.txt @@ -709,15 +709,17 @@ l5: lists { } {l1, l2, l3, l4, l5} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - arg1: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).arg1), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg1: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).arg1), + }: t_variables => Raw.t_variables + ) let makeVariables = (~arg1=?, ()): t_variables => {arg1: arg1} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/uncurried/generate/fragmentUnion.res.txt b/snapshot_tests/operations/expected/uncurried/generate/fragmentUnion.res.txt index 237333b3..e8057703 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/fragmentUnion.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/fragmentUnion.res.txt @@ -1,9 +1,11 @@ module Graphql_ppx_runtime = { // mock - let assign_typename: ( - Js.Json.t, - string, - ) => Js.Json.t = %raw(` (obj, typename) => { obj.__typename = typename; return obj } `) + let assign_typename: (Js.Json.t, string) => Js.Json.t = ( + %raw(` (obj, typename) => { obj.__typename = typename; return obj } `): ( + Js.Json.t, + string, + ) => Js.Json.t + ) } module DogFragment: { @@ocaml.warning("-32-30") diff --git a/snapshot_tests/operations/expected/uncurried/generate/hasuraRepro.res.txt b/snapshot_tests/operations/expected/uncurried/generate/hasuraRepro.res.txt index 9602645c..3ac6e8c0 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/hasuraRepro.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/hasuraRepro.res.txt @@ -118,22 +118,24 @@ hasuraRepro(orderBy: [{id: desc}], block: {number: $blockNumber, type: $type}) } {hasuraRepro: hasuraRepro} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - blockNumber: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).blockNumber), - type_: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).type_), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + blockNumber: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).blockNumber), + type_: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).type_), + }: t_variables => Raw.t_variables + ) let makeVariables = (~blockNumber=?, ~type_=?, ()): t_variables => {blockNumber, type_} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/uncurried/generate/listsArgs.res.txt b/snapshot_tests/operations/expected/uncurried/generate/listsArgs.res.txt index 9ab32d63..cfb86b9f 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/listsArgs.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/listsArgs.res.txt @@ -68,51 +68,53 @@ listsInput(arg: {nullableOfNullable: $nullableOfNullable, nullableOfNonNullable: } {listsInput: listsInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - nullableOfNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + nullableOfNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables).nullableOfNullable), + nullableOfNonNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) + } + )((inp: t_variables).nullableOfNonNullable), + nonNullableOfNullable: ( + a => + Js.Array2.map(a, b => ( a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) ) - } - )((inp: t_variables).nullableOfNullable), - nullableOfNonNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) - } - )((inp: t_variables).nullableOfNonNullable), - nonNullableOfNullable: ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )((inp: t_variables).nonNullableOfNullable), - nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( - (inp: t_variables).nonNullableOfNonNullable, - ), - } + )((inp: t_variables).nonNullableOfNullable), + nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( + (inp: t_variables).nonNullableOfNonNullable, + ), + }: t_variables => Raw.t_variables + ) let makeVariables = ( ~nullableOfNullable=?, ~nullableOfNonNullable=?, diff --git a/snapshot_tests/operations/expected/uncurried/generate/listsInput.res.txt b/snapshot_tests/operations/expected/uncurried/generate/listsInput.res.txt index c2be8b1b..97a87c50 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/listsInput.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/listsInput.res.txt @@ -74,54 +74,58 @@ listsInput(arg: $arg) } {listsInput: listsInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectListsInput(a))((inp: t_variables).arg), - } - and serializeInputObjectListsInput: t_variables_ListsInput => Raw.t_variables_ListsInput = inp => { - nullableOfNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectListsInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectListsInput: t_variables_ListsInput => Raw.t_variables_ListsInput = ( + inp => { + nullableOfNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_ListsInput).nullableOfNullable), + nullableOfNonNullable: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) + } + )((inp: t_variables_ListsInput).nullableOfNonNullable), + nonNullableOfNullable: ( + a => + Js.Array2.map(a, b => ( a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) ) - } - )((inp: t_variables_ListsInput).nullableOfNullable), - nullableOfNonNullable: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => Js.Array2.map(a, b => (a => a)(b)))(b)) - } - )((inp: t_variables_ListsInput).nullableOfNonNullable), - nonNullableOfNullable: ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )((inp: t_variables_ListsInput).nonNullableOfNullable), - nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( - (inp: t_variables_ListsInput).nonNullableOfNonNullable, - ), - } + )((inp: t_variables_ListsInput).nonNullableOfNullable), + nonNullableOfNonNullable: (a => Js.Array2.map(a, b => (a => a)(b)))( + (inp: t_variables_ListsInput).nonNullableOfNonNullable, + ), + }: t_variables_ListsInput => Raw.t_variables_ListsInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectListsInput = ( ~nullableOfNullable=?, diff --git a/snapshot_tests/operations/expected/uncurried/generate/module_type.res.txt b/snapshot_tests/operations/expected/uncurried/generate/module_type.res.txt index 7319e711..173b8c3a 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/module_type.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/module_type.res.txt @@ -263,8 +263,10 @@ and VariousScalars: { let parse = (nestedObject: MyQueryRecursive.t_nestedObject) => { otherInner: nestedObject.inner, } - let serialize: t => MyQueryRecursive.t_nestedObject = t => { - inner: t.otherInner, - } + let serialize: t => MyQueryRecursive.t_nestedObject = ( + t => { + inner: t.otherInner, + }: t => MyQueryRecursive.t_nestedObject + ) } diff --git a/snapshot_tests/operations/expected/uncurried/generate/mutationWithArgs.res.txt b/snapshot_tests/operations/expected/uncurried/generate/mutationWithArgs.res.txt index f43ea9e5..12a00d0a 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/mutationWithArgs.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/mutationWithArgs.res.txt @@ -42,9 +42,9 @@ optionalInputArgs(required: $required, anotherRequired: "val") } {optionalInputArgs: optionalInputArgs} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - required: (a => a)((inp: t_variables).required), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {required: (a => a)((inp: t_variables).required)}: t_variables => Raw.t_variables + ) let makeVariables = (~required, ()): t_variables => {required: required} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/uncurried/generate/mutationWithArgsAndNoRecords.res.txt b/snapshot_tests/operations/expected/uncurried/generate/mutationWithArgsAndNoRecords.res.txt index f43ea9e5..12a00d0a 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/mutationWithArgsAndNoRecords.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/mutationWithArgsAndNoRecords.res.txt @@ -42,9 +42,9 @@ optionalInputArgs(required: $required, anotherRequired: "val") } {optionalInputArgs: optionalInputArgs} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - required: (a => a)((inp: t_variables).required), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {required: (a => a)((inp: t_variables).required)}: t_variables => Raw.t_variables + ) let makeVariables = (~required, ()): t_variables => {required: required} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity" diff --git a/snapshot_tests/operations/expected/uncurried/generate/nonrecursiveInput.res.txt b/snapshot_tests/operations/expected/uncurried/generate/nonrecursiveInput.res.txt index 28321d03..6dff639f 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/nonrecursiveInput.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/nonrecursiveInput.res.txt @@ -90,95 +90,101 @@ nonrecursiveInput(arg: $arg) } {nonrecursiveInput: nonrecursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, @@ -315,96 +321,102 @@ more: scalarsInput(arg: $arg2) } {scalarsInput, more} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), - arg2: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg2), - } - and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = inp => { - nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), - nullableArray: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).nullableArray), - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).field), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).enum), - embeddedInput: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - Js.Array2.map(a, b => - ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) - } - )(b) - ) - )(b), - ) - } - )((inp: t_variables_NonrecursiveInput).embeddedInput), - custom: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_NonrecursiveInput).custom), - } - and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = inp => { - field: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_EmbeddedInput).field), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg), + arg2: (a => serializeInputObjectNonrecursiveInput(a))((inp: t_variables).arg2), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectNonrecursiveInput: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput = ( + inp => { + nonNullableField: (a => a)((inp: t_variables_NonrecursiveInput).nonNullableField), + nullableArray: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).nullableArray), + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).field), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).enum), + embeddedInput: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + Js.Array2.map(a, b => + ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return((a => serializeInputObjectEmbeddedInput(a))(b)) + } + )(b) + ) + )(b), + ) + } + )((inp: t_variables_NonrecursiveInput).embeddedInput), + custom: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_NonrecursiveInput).custom), + }: t_variables_NonrecursiveInput => Raw.t_variables_NonrecursiveInput + ) + and serializeInputObjectEmbeddedInput: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput = ( + inp => { + field: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_EmbeddedInput).field), + }: t_variables_EmbeddedInput => Raw.t_variables_EmbeddedInput + ) let makeVariables = (~arg, ~arg2, ()): t_variables => {arg, arg2} and makeInputObjectNonrecursiveInput = ( ~nonNullableField, diff --git a/snapshot_tests/operations/expected/uncurried/generate/pokedexScalars.res.txt b/snapshot_tests/operations/expected/uncurried/generate/pokedexScalars.res.txt index 80eabff2..95d7906b 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/pokedexScalars.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/pokedexScalars.res.txt @@ -101,22 +101,24 @@ name } {pokemon: pokemon} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - id: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).id), - name: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).name), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + id: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).id), + name: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).name), + }: t_variables => Raw.t_variables + ) let makeVariables = (~id=?, ~name=?, ()): t_variables => {id, name} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" @@ -226,22 +228,24 @@ name } {pokemon: pokemon} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - id: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).id), - name: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).name), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + id: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).id), + name: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).name), + }: t_variables => Raw.t_variables + ) let makeVariables = (~id=?, ~name=?, ()): t_variables => {id, name} let makeDefaultVariables = () => makeVariables() external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" diff --git a/snapshot_tests/operations/expected/uncurried/generate/recursiveInput.res.txt b/snapshot_tests/operations/expected/uncurried/generate/recursiveInput.res.txt index 61216a2f..11ef8b06 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/recursiveInput.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/recursiveInput.res.txt @@ -69,42 +69,46 @@ recursiveInput(arg: $arg) } {recursiveInput: recursiveInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectRecursiveInput(a))((inp: t_variables).arg), - } - and serializeInputObjectRecursiveInput: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput = inp => { - otherField: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_RecursiveInput).otherField), - inner: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectRecursiveInput(a))(b)) - } - )((inp: t_variables_RecursiveInput).inner), - enum: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => - Js.Nullable.return( - ( - a => - switch a { - | #FIRST => "FIRST" - | #SECOND => "SECOND" - | #THIRD => "THIRD" - } - )(b), - ) - } - )((inp: t_variables_RecursiveInput).enum), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectRecursiveInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectRecursiveInput: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput = ( + inp => { + otherField: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_RecursiveInput).otherField), + inner: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectRecursiveInput(a))(b)) + } + )((inp: t_variables_RecursiveInput).inner), + enum: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => + Js.Nullable.return( + ( + a => + switch a { + | #FIRST => "FIRST" + | #SECOND => "SECOND" + | #THIRD => "THIRD" + } + )(b), + ) + } + )((inp: t_variables_RecursiveInput).enum), + }: t_variables_RecursiveInput => Raw.t_variables_RecursiveInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectRecursiveInput = ( ~otherField=?, @@ -200,37 +204,45 @@ recursiveRepro(input: $input) } {recursiveRepro: recursiveRepro} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - input: (a => serializeInputObjectproblem_input(a))((inp: t_variables).input), - } - and serializeInputObjectproblem_input: t_variables_problem_input => Raw.t_variables_problem_input = inp => { - the_problem: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) - } - )((inp: t_variables_problem_input).the_problem), - b: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectnested_type(a))(b)) - } - )((inp: t_variables_problem_input).b), - } - and serializeInputObjectthis_will_be_duplicated: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated = inp => { - id: (a => a)((inp: t_variables_this_will_be_duplicated).id), - } - and serializeInputObjectnested_type: t_variables_nested_type => Raw.t_variables_nested_type = inp => { - the_problem: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) - } - )((inp: t_variables_nested_type).the_problem), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + input: (a => serializeInputObjectproblem_input(a))((inp: t_variables).input), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectproblem_input: t_variables_problem_input => Raw.t_variables_problem_input = ( + inp => { + the_problem: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) + } + )((inp: t_variables_problem_input).the_problem), + b: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectnested_type(a))(b)) + } + )((inp: t_variables_problem_input).b), + }: t_variables_problem_input => Raw.t_variables_problem_input + ) + and serializeInputObjectthis_will_be_duplicated: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated = ( + inp => { + id: (a => a)((inp: t_variables_this_will_be_duplicated).id), + }: t_variables_this_will_be_duplicated => Raw.t_variables_this_will_be_duplicated + ) + and serializeInputObjectnested_type: t_variables_nested_type => Raw.t_variables_nested_type = ( + inp => { + the_problem: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => serializeInputObjectthis_will_be_duplicated(a))(b)) + } + )((inp: t_variables_nested_type).the_problem), + }: t_variables_nested_type => Raw.t_variables_nested_type + ) let makeVariables = (~input, ()): t_variables => {input: input} and makeInputObjectproblem_input = (~the_problem=?, ~b=?, ()): t_variables_problem_input => { the_problem, diff --git a/snapshot_tests/operations/expected/uncurried/generate/scalarsArgs.res.txt b/snapshot_tests/operations/expected/uncurried/generate/scalarsArgs.res.txt index 97ccd80e..6ea92db9 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/scalarsArgs.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/scalarsArgs.res.txt @@ -98,48 +98,50 @@ scalarsInput(arg: {nullableString: $nullableString, string: $string, nullableInt } {scalarsInput: scalarsInput} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - nullableString: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableString), - string: (a => a)((inp: t_variables).string), - nullableInt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableInt), - int: (a => a)((inp: t_variables).int), - nullableFloat: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableFloat), - float: (a => a)((inp: t_variables).float), - nullableBoolean: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableBoolean), - boolean: (a => a)((inp: t_variables).boolean), - nullableID: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables).nullableID), - id: (a => a)((inp: t_variables).id), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => { + nullableString: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableString), + string: (a => a)((inp: t_variables).string), + nullableInt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableInt), + int: (a => a)((inp: t_variables).int), + nullableFloat: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableFloat), + float: (a => a)((inp: t_variables).float), + nullableBoolean: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableBoolean), + boolean: (a => a)((inp: t_variables).boolean), + nullableID: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables).nullableID), + id: (a => a)((inp: t_variables).id), + }: t_variables => Raw.t_variables + ) let makeVariables = ( ~nullableString=?, ~string, diff --git a/snapshot_tests/operations/expected/uncurried/generate/scalarsInput.res.txt b/snapshot_tests/operations/expected/uncurried/generate/scalarsInput.res.txt index 513766f9..60a634ea 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/scalarsInput.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/scalarsInput.res.txt @@ -104,51 +104,55 @@ scalarsInput(arg: $arg) } {scalarsInput: scalarsInput} } - let rec serializeVariables: t_variables => Raw.t_variables = inp => { - arg: (a => serializeInputObjectVariousScalarsInput(a))((inp: t_variables).arg), - } - and serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput = inp => { - nullableString: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableString), - string: (a => a)((inp: t_variables_VariousScalarsInput).string), - nullableInt: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableInt), - int: (a => a)((inp: t_variables_VariousScalarsInput).int), - nullableFloat: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableFloat), - float: (a => a)((inp: t_variables_VariousScalarsInput).float), - nullableBoolean: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableBoolean), - boolean: (a => a)((inp: t_variables_VariousScalarsInput).boolean), - nullableID: ( - a => - switch a { - | None => Js.Nullable.undefined - | Some(b) => Js.Nullable.return((a => a)(b)) - } - )((inp: t_variables_VariousScalarsInput).nullableID), - id: (a => a)((inp: t_variables_VariousScalarsInput).id), - } + let rec serializeVariables: t_variables => Raw.t_variables = ( + inp => { + arg: (a => serializeInputObjectVariousScalarsInput(a))((inp: t_variables).arg), + }: t_variables => Raw.t_variables + ) + and serializeInputObjectVariousScalarsInput: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput = ( + inp => { + nullableString: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableString), + string: (a => a)((inp: t_variables_VariousScalarsInput).string), + nullableInt: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableInt), + int: (a => a)((inp: t_variables_VariousScalarsInput).int), + nullableFloat: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableFloat), + float: (a => a)((inp: t_variables_VariousScalarsInput).float), + nullableBoolean: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableBoolean), + boolean: (a => a)((inp: t_variables_VariousScalarsInput).boolean), + nullableID: ( + a => + switch a { + | None => Js.Nullable.undefined + | Some(b) => Js.Nullable.return((a => a)(b)) + } + )((inp: t_variables_VariousScalarsInput).nullableID), + id: (a => a)((inp: t_variables_VariousScalarsInput).id), + }: t_variables_VariousScalarsInput => Raw.t_variables_VariousScalarsInput + ) let makeVariables = (~arg, ()): t_variables => {arg: arg} and makeInputObjectVariousScalarsInput = ( ~nullableString=?, diff --git a/snapshot_tests/operations/expected/uncurried/generate/skipDirectives.res.txt b/snapshot_tests/operations/expected/uncurried/generate/skipDirectives.res.txt index 2e6b6c16..317bc5e8 100644 --- a/snapshot_tests/operations/expected/uncurried/generate/skipDirectives.res.txt +++ b/snapshot_tests/operations/expected/uncurried/generate/skipDirectives.res.txt @@ -164,9 +164,9 @@ string @include(if: $var) } {v1, v2} } - let serializeVariables: t_variables => Raw.t_variables = inp => { - var: (a => a)((inp: t_variables).var), - } + let serializeVariables: t_variables => Raw.t_variables = ( + inp => {var: (a => a)((inp: t_variables).var)}: t_variables => Raw.t_variables + ) let makeVariables = (~var, ()): t_variables => {var: var} external unsafe_fromJson: Js.Json.t => Raw.t = "%identity" external toJson: Raw.t => Js.Json.t = "%identity"