From 067bd1aa1165eed1acad544d065879e6626bdcbd Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Thu, 24 Apr 2025 11:44:21 -0700 Subject: [PATCH] Make fields nullable not optional when semantic nullability is used Differential Revision: D67054462 --- .../client_mutation_resolver.expected | 4 +- ...on_resolver_different_mutation_ok.expected | 4 +- ...sion_interface_uses_resolver_type.expected | 10 +- .../fixtures/error_handling_fragment.expected | 4 +- .../fixtures/error_handling_query.expected | 8 +- ...vers_directive_with_root_fragment.expected | 4 +- ...nterface_of_all_strong_model_type.expected | 6 +- ...resolvers_in_throw_on_field_error.expected | 10 +- ...nterface_of_all_strong_model_type.expected | 4 +- ...l_strong_model_type_including_cse.expected | 4 +- ...ong_model_type_with_root_fragment.expected | 4 +- ..._interface_of_all_weak_model_type.expected | 4 +- ...urns_client_schema_extension_enum.expected | 4 +- ...ver_returns_enum_with_enum_suffix.expected | 4 +- ..._interface_of_all_live_model_type.expected | 6 +- ...nterface_of_all_strong_model_type.expected | 6 +- ...l_strong_model_type_including_cse.expected | 6 +- ..._interface_of_all_weak_model_type.expected | 4 +- ...ve_and_non_live_strong_model_type.expected | 6 +- .../resolver_returns_union_of_cse.expected | 10 +- ..._returns_union_of_strong_resolver.expected | 10 +- .../fixtures/resolvers_schema_module.expected | 4 +- ...module_apply_to_normalization_ast.expected | 4 +- .../semantic_null_require_bubbling.expected | 6 +- ...ce_fragment_on_weak_concrete_type.expected | 4 +- ...erface_fragments_on_concrete_type.expected | 8 +- .../typescript_resolver_type_import.expected | 4 +- .../typescript_resolver_with_context.expected | 4 +- compiler/crates/relay-typegen/src/flow.rs | 24 +++- .../relay-typegen/src/type_selection.rs | 1 + .../crates/relay-typegen/src/typescript.rs | 33 +++-- compiler/crates/relay-typegen/src/visit.rs | 113 ++++++++++++------ compiler/crates/relay-typegen/src/writer.rs | 3 + .../catch-no-arg-nested-linked.expected | 4 +- .../catch-on-aliased-inline-fragment.expected | 2 +- .../fixtures/catch-on-mutation.expected | 10 +- .../fixtures/catch-on-root.expected | 2 +- ...antic-non-null-with-catch-to-null.expected | 2 +- ...o-null-on-aliased-inline-fragment.expected | 2 +- .../catch-to-null-on-fragment.expected | 2 +- .../fixtures/catch-to-null-on-query.expected | 6 +- ...result-on-aliased-inline-fragment.expected | 2 +- .../catch-to-result-on-fragment.expected | 2 +- .../catch-to-result-on-query.expected | 6 +- .../relay-live-resolver-no-fragment.expected | 2 +- ...olver-with-field-args-no-fragment.expected | 2 +- ...lay-live-resolver-with-field-args.expected | 2 +- .../fixtures/relay-live-resolver.expected | 2 +- ...lay-resolver-client-edge-required.expected | 4 +- .../relay-resolver-client-edge.expected | 4 +- .../relay-resolver-in-fragment.expected | 2 +- ...lay-resolver-inject-fragment-data.expected | 2 +- .../relay-resolver-live-client-edge.expected | 4 +- ...relay-resolver-multiple-consumers.expected | 2 +- .../relay-resolver-named-import.expected | 2 +- ...al-client-edge-with-required-edge.expected | 4 +- ...relay-resolver-plural-client-edge.expected | 4 +- ...olver-plural-required-client-edge.expected | 4 +- .../relay-resolver-raw-response.expected | 2 +- .../fixtures/relay-resolver-required.expected | 2 +- .../relay-resolver-scalar-plural.expected | 2 +- ...with-output-type-client-interface.expected | 2 +- ...-output-type-client-object-plural.expected | 2 +- ...er-with-output-type-client-object.expected | 2 +- ...lver-with-output-type-enum-plural.expected | 2 +- ...ay-resolver-with-output-type-enum.expected | 2 +- ...-type-relay-resolver-value-plural.expected | 2 +- ...ype-relay-resolver-value-required.expected | 2 +- ...-output-type-relay-resolver-value.expected | 2 +- ...er-with-output-type-scalar-plural.expected | 2 +- ...-with-output-type-scalar-required.expected | 2 +- ...-resolver-with-output-type-scalar.expected | 2 +- .../fixtures/relay-resolver.expected | 2 +- ...-strong-model-type-with-extension.expected | 2 +- ...ong-model-type-with-root-fragment.expected | 4 +- ...nterface-of-all-strong-model-type.expected | 2 +- ...-interface-of-all-weak-model-type.expected | 2 +- ...semantic_non_null_in_raw_response.expected | 8 +- ...semantic_non_null_items_in_matrix.expected | 2 +- ...tic_non_null_liked_field_resolver.expected | 2 +- ...on_null_liked_field_weak_resolver.expected | 2 +- .../semantic_non_null_linked_field.expected | 2 +- .../semantic_non_null_list_item.expected | 2 +- ...ntic_null_required_throw_on_error.expected | 2 +- .../catch-no-arg-nested-linked.expected | 4 +- ...antic-non-null-with-catch-to-null.expected | 2 +- ...nked-semantic-non-null-with-catch.expected | 2 +- ...esolver-on-query-with-output-type.expected | 2 +- ...with-output-type-client-interface.expected | 2 +- ...er-with-output-type-client-object.expected | 2 +- ...ype-relay-resolver-value-required.expected | 2 +- ...-output-type-relay-resolver-value.expected | 2 +- ...n-null-deeply-nested-within-catch.expected | 2 +- ...semantic_non_null_in_raw_response.expected | 6 +- ...semantic_non_null_items_in_matrix.expected | 2 +- ...tic_non_null_liked_field_resolver.expected | 2 +- ...on_null_liked_field_weak_resolver.expected | 2 +- .../semantic_non_null_linked_field.expected | 2 +- .../semantic_non_null_list_item.expected | 2 +- 99 files changed, 289 insertions(+), 217 deletions(-) diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_resolver.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_resolver.expected index eef55a7db8795..14868bc0185df 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_resolver.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_resolver.expected @@ -30,7 +30,7 @@ type Query { ==================================== OUTPUT =================================== //- __generated__/barMutation.graphql.js /** - * SignedSource<<7f1de50339842bab9cecc72c6fbc076f>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -45,7 +45,7 @@ import type { ClientRequest, Mutation } from 'relay-runtime'; import {foo_mutation as mutationFooMutationResolverType} from "../foo.js"; // Type assertion validating that `mutationFooMutationResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(mutationFooMutationResolverType: () => ?boolean); +(mutationFooMutationResolverType: () => boolean | null); export type barMutation$variables = {||}; export type barMutation$data = {| +foo_mutation: ?boolean, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_resolver_different_mutation_ok.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_resolver_different_mutation_ok.expected index f998a1dbb8a66..dd9df7c4b98ae 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_resolver_different_mutation_ok.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_resolver_different_mutation_ok.expected @@ -104,7 +104,7 @@ export default node; //- __generated__/barMutation.graphql.js /** - * SignedSource<<6f79ca8d7718498c480388c5b22a5130>> + * SignedSource<<31cc6cb3ca0668ffe6884f2da3893466>> * @flow * @lightSyntaxTransform * @nogrep @@ -119,7 +119,7 @@ import type { ClientRequest, Mutation } from 'relay-runtime'; import {baz_mutation as notCalledMutationBazMutationResolverType} from "../foo.js"; // Type assertion validating that `notCalledMutationBazMutationResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(notCalledMutationBazMutationResolverType: () => ?boolean); +(notCalledMutationBazMutationResolverType: () => boolean | null); export type barMutation$variables = {||}; export type barMutation$data = {| +baz_mutation: ?boolean, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_schema_extension_interface_uses_resolver_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_schema_extension_interface_uses_resolver_type.expected index de5c9bfc25d07..52e3ee7da6b46 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_schema_extension_interface_uses_resolver_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_schema_extension_interface_uses_resolver_type.expected @@ -176,7 +176,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<<6c11d65c79f10f8cbe664d4735a1fb15>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -195,15 +195,15 @@ import {admin as adminAdminResolverType} from "Admin"; // A type error here indicates that the type signature of the resolver module is incorrect. (adminAdminResolverType: ( __relay_model_instance: Admin____relay_model_instance$data['__relay_model_instance'], -) => ?{| +) => {| +id: DataID, -|}); +|} | null); import {boss as queryBossResolverType} from "Admin"; // Type assertion validating that `queryBossResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(queryBossResolverType: () => ?{| +(queryBossResolverType: () => {| +id: DataID, -|}); +|} | null); export type PersonComponentQuery$variables = {||}; export type PersonComponentQuery$data = {| +boss: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/error_handling_fragment.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/error_handling_fragment.expected index cfd5644610b28..0b4e5e1c89fd5 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/error_handling_fragment.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/error_handling_fragment.expected @@ -17,7 +17,7 @@ type User { name: String } ==================================== OUTPUT =================================== //- __generated__/foo.graphql.js /** - * SignedSource<> + * SignedSource<<70a7a244e5796d4e6e9f2fbcd76c50f0>> * @flow * @lightSyntaxTransform * @nogrep @@ -32,7 +32,7 @@ import type { Fragment, ReaderFragment } from 'relay-runtime'; import type { FragmentType } from "relay-runtime"; declare export opaque type foo$fragmentType: FragmentType; export type foo$data = {| - +name: ?string, + +name: string | null, +$fragmentType: foo$fragmentType, |}; export type foo$key = { diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/error_handling_query.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/error_handling_query.expected index 8f76bcfe6859a..4c6cf2ecda5cc 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/error_handling_query.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/error_handling_query.expected @@ -19,7 +19,7 @@ type User { name: String } ==================================== OUTPUT =================================== //- __generated__/fooQuery.graphql.js /** - * SignedSource<<9b5cf0134e02913bc0d65df99f7ff0c3>> + * SignedSource<<2850659094fb71d3762177cc38cd028d>> * @flow * @lightSyntaxTransform * @nogrep @@ -33,9 +33,9 @@ type User { name: String } import type { ConcreteRequest, Query } from 'relay-runtime'; export type fooQuery$variables = {||}; export type fooQuery$data = {| - +me: ?{| - +name: ?string, - |}, + +me: {| + +name: string | null, + |} | null, |}; export type fooQuery = {| response: fooQuery$data, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/exec_resolvers_directive_with_root_fragment.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/exec_resolvers_directive_with_root_fragment.expected index 2ea58bb4d56e2..eea31b0e262fb 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/exec_resolvers_directive_with_root_fragment.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/exec_resolvers_directive_with_root_fragment.expected @@ -116,7 +116,7 @@ export default node; //- __generated__/UserFooFragment.graphql.js /** - * SignedSource<<843aee583dbf963998562b8559b43846>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -132,7 +132,7 @@ import type { FragmentType } from "relay-runtime"; import {bar as userBarResolverType} from "User_bar"; // Type assertion validating that `userBarResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(userBarResolverType: () => ?mixed); +(userBarResolverType: () => mixed | null); declare export opaque type UserFooFragment$fragmentType: FragmentType; export type UserFooFragment$data = {| +bar: ?ReturnType, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_on_interface_of_all_strong_model_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_on_interface_of_all_strong_model_type.expected index 1dcde374e51dc..7546ffb2ef23b 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_on_interface_of_all_strong_model_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_on_interface_of_all_strong_model_type.expected @@ -183,7 +183,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<> + * SignedSource<<63481a634199f0ea7757f9e303b9a3c8>> * @flow * @lightSyntaxTransform * @nogrep @@ -202,13 +202,13 @@ import {description as iActorDescriptionResolverType} from "IActorResolvers"; // A type error here indicates that the type signature of the resolver module is incorrect. (iActorDescriptionResolverType: ( model: Admin____relay_model_instance$data['__relay_model_instance'] | User____relay_model_instance$data['__relay_model_instance'], -) => ?string); +) => string | null); import {name as iPersonNameResolverType} from "IPersonResolvers"; // Type assertion validating that `iPersonNameResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. (iPersonNameResolverType: ( model: Admin____relay_model_instance$data['__relay_model_instance'] | User____relay_model_instance$data['__relay_model_instance'], -) => ?string); +) => string | null); export type PersonComponentQuery$variables = {||}; export type PersonComponentQuery$data = {| +actor: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/relay_resolvers_in_throw_on_field_error.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/relay_resolvers_in_throw_on_field_error.expected index da2284f8150d6..0b977428e2da1 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/relay_resolvers_in_throw_on_field_error.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/relay_resolvers_in_throw_on_field_error.expected @@ -164,7 +164,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/fooQuery.graphql.js /** - * SignedSource<<3313eddbfdd22f715c9f61877c3934fc>> + * SignedSource<<31bc07f2b00ed403e2ce86668617d4b8>> * @flow * @lightSyntaxTransform * @nogrep @@ -180,14 +180,14 @@ import type { DataID } from "relay-runtime"; import {clientUser as queryClientUserResolverType} from "foo"; // Type assertion validating that `queryClientUserResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(queryClientUserResolverType: () => ?{| +(queryClientUserResolverType: () => {| +id: DataID, -|}); +|} | null); export type fooQuery$variables = {||}; export type fooQuery$data = {| - +clientUser: ?{| + +clientUser: {| +id: string, - |}, + |} | null, |}; export type fooQuery = {| response: fooQuery$data, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type.expected index 578165e56e6ee..069b99e145188 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type.expected @@ -168,7 +168,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentFragment.graphql.js /** - * SignedSource<> + * SignedSource<<6ae25904008fca5dd338ee1e53ed18d2>> * @flow * @lightSyntaxTransform * @nogrep @@ -188,7 +188,7 @@ import {name as iPersonNameResolverType} from "IPersonResolvers"; // A type error here indicates that the type signature of the resolver module is incorrect. (iPersonNameResolverType: ( model: Admin____relay_model_instance$data['__relay_model_instance'] | User____relay_model_instance$data['__relay_model_instance'], -) => ?string); +) => string | null); declare export opaque type PersonComponentFragment$fragmentType: FragmentType; export type PersonComponentFragment$data = {| +name: ?string, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type_including_cse.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type_including_cse.expected index 4b6c934884b84..7046d779ac530 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type_including_cse.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type_including_cse.expected @@ -173,7 +173,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentFragment.graphql.js /** - * SignedSource<> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -193,7 +193,7 @@ import {name as iPersonNameResolverType} from "IPersonResolvers"; // A type error here indicates that the type signature of the resolver module is incorrect. (iPersonNameResolverType: ( model: Admin____relay_model_instance$data['__relay_model_instance'] | User____relay_model_instance$data['__relay_model_instance'], -) => ?string); +) => string | null); declare export opaque type PersonComponentFragment$fragmentType: FragmentType; export type PersonComponentFragment$data = {| +name: ?string, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type_with_root_fragment.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type_with_root_fragment.expected index d94fd6fa66c87..077020b96b04c 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type_with_root_fragment.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_strong_model_type_with_root_fragment.expected @@ -171,7 +171,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/IPersonResolversFragment.graphql.js /** - * SignedSource<> + * SignedSource<<3039ac5c36d275852823d4328779d54d>> * @flow * @lightSyntaxTransform * @nogrep @@ -189,7 +189,7 @@ import {name as iPersonNameResolverType} from "IPersonResolvers"; // A type error here indicates that the type signature of the resolver module is incorrect. (iPersonNameResolverType: ( rootKey: IPersonResolversFragment$key, -) => ?string); +) => string | null); declare export opaque type IPersonResolversFragment$fragmentType: FragmentType; export type IPersonResolversFragment$data = {| +name: ?string, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_weak_model_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_weak_model_type.expected index 7231837754c5c..212ad925b7bdb 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_weak_model_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_on_interface_of_all_weak_model_type.expected @@ -102,7 +102,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentFragment.graphql.js /** - * SignedSource<> + * SignedSource<<6ae25904008fca5dd338ee1e53ed18d2>> * @flow * @lightSyntaxTransform * @nogrep @@ -122,7 +122,7 @@ import {name as iPersonNameResolverType} from "IPersonResolvers"; // A type error here indicates that the type signature of the resolver module is incorrect. (iPersonNameResolverType: ( model: Admin____relay_model_instance$data['__relay_model_instance'] | User____relay_model_instance$data['__relay_model_instance'], -) => ?string); +) => string | null); declare export opaque type PersonComponentFragment$fragmentType: FragmentType; export type PersonComponentFragment$data = {| +name: ?string, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_client_schema_extension_enum.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_client_schema_extension_enum.expected index 9e2859951d643..546c1042fb26e 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_client_schema_extension_enum.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_client_schema_extension_enum.expected @@ -45,7 +45,7 @@ enum Status { ==================================== OUTPUT =================================== //- __generated__/SomeComponentFragment.graphql.js /** - * SignedSource<> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -65,7 +65,7 @@ import {status as userStatusResolverType} from "UserTypeResolvers"; // A type error here indicates that the type signature of the resolver module is incorrect. (userStatusResolverType: ( __relay_model_instance: User____relay_model_instance$data['__relay_model_instance'], -) => ?Status); +) => Status | null); declare export opaque type SomeComponentFragment$fragmentType: FragmentType; export type SomeComponentFragment$data = {| +status: ?Status, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_enum_with_enum_suffix.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_enum_with_enum_suffix.expected index c3aa2f66925b7..4c1d39b391ba4 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_enum_with_enum_suffix.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_enum_with_enum_suffix.expected @@ -46,7 +46,7 @@ enum Status { ==================================== OUTPUT =================================== //- __generated__/SomeComponentFragment.graphql.js /** - * SignedSource<> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -66,7 +66,7 @@ import {status as userStatusResolverType} from "UserTypeResolvers"; // A type error here indicates that the type signature of the resolver module is incorrect. (userStatusResolverType: ( __relay_model_instance: User____relay_model_instance$data['__relay_model_instance'], -) => ?Status); +) => Status | null); declare export opaque type SomeComponentFragment$fragmentType: FragmentType; export type SomeComponentFragment$data = {| +status: ?Status, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_live_model_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_live_model_type.expected index 93d720ea85584..3a4a71d148130 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_live_model_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_live_model_type.expected @@ -179,7 +179,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/QueryComponentQuery.graphql.js /** - * SignedSource<<039b56847e2dfd47111f7874367eec4c>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -195,10 +195,10 @@ import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(queryPersonResolverType: () => ?{| +(queryPersonResolverType: () => {| +__typename: "Admin" | "User", +id: DataID, -|}); +|} | null); export type QueryComponentQuery$variables = {||}; export type QueryComponentQuery$data = {| +person: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_strong_model_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_strong_model_type.expected index 6af1b4f8501e2..5cdfef4b08822 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_strong_model_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_strong_model_type.expected @@ -177,7 +177,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<<82abcf281482a29fac0483ffd358760a>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -193,10 +193,10 @@ import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(queryPersonResolverType: () => ?{| +(queryPersonResolverType: () => {| +__typename: "Admin" | "User", +id: DataID, -|}); +|} | null); export type PersonComponentQuery$variables = {||}; export type PersonComponentQuery$data = {| +person: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_strong_model_type_including_cse.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_strong_model_type_including_cse.expected index 115540b7b8399..b4be623e32a64 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_strong_model_type_including_cse.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_strong_model_type_including_cse.expected @@ -182,7 +182,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<<2250f9a6d065f577c499160ece6f071f>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -198,10 +198,10 @@ import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(queryPersonResolverType: () => ?{| +(queryPersonResolverType: () => {| +__typename: "Admin" | "User" | "Visitor", +id: DataID, -|}); +|} | null); export type PersonComponentQuery$variables = {||}; export type PersonComponentQuery$data = {| +person: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_weak_model_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_weak_model_type.expected index b697cbebd4ba3..9b5c42d0c6938 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_weak_model_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_all_weak_model_type.expected @@ -113,7 +113,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/QueryComponentQuery.graphql.js /** - * SignedSource<<1e557ef442e027c83b6204650e80e65f>> + * SignedSource<<39a6f90dac3aa0fee8284f8358435b25>> * @flow * @lightSyntaxTransform * @nogrep @@ -128,7 +128,7 @@ import type { ClientRequest, ClientQuery } from 'relay-runtime'; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(queryPersonResolverType: () => ?Query__person$normalization); +(queryPersonResolverType: () => Query__person$normalization | null); import type { Query__person$normalization } from "Query__person$normalization.graphql"; export type QueryComponentQuery$variables = {||}; export type QueryComponentQuery$data = {| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_live_and_non_live_strong_model_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_live_and_non_live_strong_model_type.expected index 815bbee1a5e77..755858b49f279 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_live_and_non_live_strong_model_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_interface_of_live_and_non_live_strong_model_type.expected @@ -178,7 +178,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/QueryComponentQuery.graphql.js /** - * SignedSource<<5b3a040936e731b1c6d0976643c9fbe8>> + * SignedSource<<712c7fb44362dac9f0978c3f085aeaef>> * @flow * @lightSyntaxTransform * @nogrep @@ -194,10 +194,10 @@ import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(queryPersonResolverType: () => ?{| +(queryPersonResolverType: () => {| +__typename: "Admin" | "User", +id: DataID, -|}); +|} | null); export type QueryComponentQuery$variables = {||}; export type QueryComponentQuery$data = {| +person: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_union_of_cse.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_union_of_cse.expected index 56dfe64ba798a..bb3143e853982 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_union_of_cse.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_union_of_cse.expected @@ -57,7 +57,7 @@ union Person = User | Admin ==================================== OUTPUT =================================== //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<<140d4139905c84426daa58015486e9c1>> + * SignedSource<<5ba21634369f9783ae8b2946a17e2052>> * @flow * @lightSyntaxTransform * @nogrep @@ -73,18 +73,18 @@ import type { DataID } from "relay-runtime"; import {name as adminNameResolverType} from "AdminTypeResolvers"; // Type assertion validating that `adminNameResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(adminNameResolverType: () => ?string); +(adminNameResolverType: () => string | null); import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(queryPersonResolverType: () => ?{| +(queryPersonResolverType: () => {| +__typename: "Admin" | "User", +id: DataID, -|}); +|} | null); import {name as userNameResolverType} from "UserTypeResolvers"; // Type assertion validating that `userNameResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(userNameResolverType: () => ?string); +(userNameResolverType: () => string | null); export type PersonComponentQuery$variables = {||}; export type PersonComponentQuery$data = {| +person: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_union_of_strong_resolver.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_union_of_strong_resolver.expected index bffc089ab4bd8..05263877837a1 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_union_of_strong_resolver.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolver_returns_union_of_strong_resolver.expected @@ -180,7 +180,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<<782f49240ee45f68c45dda145b634f84>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -200,20 +200,20 @@ import {name as adminNameResolverType} from "AdminTypeResolvers"; // A type error here indicates that the type signature of the resolver module is incorrect. (adminNameResolverType: ( __relay_model_instance: Admin____relay_model_instance$data['__relay_model_instance'], -) => ?string); +) => string | null); import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(queryPersonResolverType: () => ?{| +(queryPersonResolverType: () => {| +__typename: "Admin" | "User", +id: DataID, -|}); +|} | null); import {name as userNameResolverType} from "UserTypeResolvers"; // Type assertion validating that `userNameResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. (userNameResolverType: ( __relay_model_instance: User____relay_model_instance$data['__relay_model_instance'], -) => ?string); +) => string | null); export type PersonComponentQuery$variables = {||}; export type PersonComponentQuery$data = {| +person: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolvers_schema_module.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolvers_schema_module.expected index 6a18e321fa498..3358299bd9eee 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolvers_schema_module.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolvers_schema_module.expected @@ -116,7 +116,7 @@ export default node; //- __generated__/UserFooFragment.graphql.js /** - * SignedSource<<843aee583dbf963998562b8559b43846>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -132,7 +132,7 @@ import type { FragmentType } from "relay-runtime"; import {bar as userBarResolverType} from "User_bar"; // Type assertion validating that `userBarResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(userBarResolverType: () => ?mixed); +(userBarResolverType: () => mixed | null); declare export opaque type UserFooFragment$fragmentType: FragmentType; export type UserFooFragment$data = {| +bar: ?ReturnType, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolvers_schema_module_apply_to_normalization_ast.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolvers_schema_module_apply_to_normalization_ast.expected index 65f42340c908d..f1213ae13e297 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolvers_schema_module_apply_to_normalization_ast.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/resolvers_schema_module_apply_to_normalization_ast.expected @@ -112,7 +112,7 @@ export default node; //- __generated__/UserFooFragment.graphql.js /** - * SignedSource<<843aee583dbf963998562b8559b43846>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -128,7 +128,7 @@ import type { FragmentType } from "relay-runtime"; import {bar as userBarResolverType} from "User_bar"; // Type assertion validating that `userBarResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(userBarResolverType: () => ?mixed); +(userBarResolverType: () => mixed | null); declare export opaque type UserFooFragment$fragmentType: FragmentType; export type UserFooFragment$data = {| +bar: ?ReturnType, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/semantic_null_require_bubbling.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/semantic_null_require_bubbling.expected index f9a6bfd4ee629..2c829d06726a3 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/semantic_null_require_bubbling.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/semantic_null_require_bubbling.expected @@ -24,7 +24,7 @@ type Person { ==================================== OUTPUT =================================== //- __generated__/PersonComponentFragment.graphql.js /** - * SignedSource<> + * SignedSource<<0b312efbb631920c43da94a7f1c6bcff>> * @flow * @lightSyntaxTransform * @nogrep @@ -39,9 +39,9 @@ import type { Fragment, ReaderFragment } from 'relay-runtime'; import type { FragmentType } from "relay-runtime"; declare export opaque type PersonComponentFragment$fragmentType: FragmentType; export type PersonComponentFragment$data = {| - +some_person: ?{| + +some_person: {| +name: string, - |}, + |} | null, +$fragmentType: PersonComponentFragment$fragmentType, |}; export type PersonComponentFragment$key = { diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/spread_interface_fragment_on_weak_concrete_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/spread_interface_fragment_on_weak_concrete_type.expected index e83043157ac55..e99ceb2df67c5 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/spread_interface_fragment_on_weak_concrete_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/spread_interface_fragment_on_weak_concrete_type.expected @@ -216,7 +216,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/UserQueryComponentQuery.graphql.js /** - * SignedSource<> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -232,7 +232,7 @@ import type { PersonComponentFragment$fragmentType } from "PersonComponentFragme import {user as queryUserResolverType} from "UserTypeResolvers"; // Type assertion validating that `queryUserResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(queryUserResolverType: () => ?User); +(queryUserResolverType: () => User | null); import type { User } from "UserTypeResolvers"; export type UserQueryComponentQuery$variables = {||}; export type UserQueryComponentQuery$data = {| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/spread_multiple_interface_fragments_on_concrete_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/spread_multiple_interface_fragments_on_concrete_type.expected index f32712d1bac06..2562f183f0667 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/spread_multiple_interface_fragments_on_concrete_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/spread_multiple_interface_fragments_on_concrete_type.expected @@ -66,7 +66,7 @@ interface IActor { ==================================== OUTPUT =================================== //- __generated__/ActorComponentFragment.graphql.js /** - * SignedSource<<8ecf1496c9be81fba75d8d8bf501e19b>> + * SignedSource<<626cf872bac35331edf55278511c0458>> * @flow * @lightSyntaxTransform * @nogrep @@ -86,7 +86,7 @@ import {description as iActorDescriptionResolverType} from "IActorResolvers"; // A type error here indicates that the type signature of the resolver module is incorrect. (iActorDescriptionResolverType: ( model: Admin____relay_model_instance$data['__relay_model_instance'] | User____relay_model_instance$data['__relay_model_instance'], -) => ?string); +) => string | null); declare export opaque type ActorComponentFragment$fragmentType: FragmentType; export type ActorComponentFragment$data = {| +description: ?string, @@ -292,7 +292,7 @@ export default ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentFragment.graphql.js /** - * SignedSource<> + * SignedSource<<6ae25904008fca5dd338ee1e53ed18d2>> * @flow * @lightSyntaxTransform * @nogrep @@ -312,7 +312,7 @@ import {name as iPersonNameResolverType} from "IPersonResolvers"; // A type error here indicates that the type signature of the resolver module is incorrect. (iPersonNameResolverType: ( model: Admin____relay_model_instance$data['__relay_model_instance'] | User____relay_model_instance$data['__relay_model_instance'], -) => ?string); +) => string | null); declare export opaque type PersonComponentFragment$fragmentType: FragmentType; export type PersonComponentFragment$data = {| +name: ?string, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.expected index b70fb4a9c12c5..e29bd3c2e3e70 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.expected @@ -21,7 +21,7 @@ type User { name: String } ==================================== OUTPUT =================================== //- __generated__/barFragment.graphql.ts /** - * SignedSource<<0f778584db7b20b3491a3ed42c61cdc1>> + * SignedSource<<284259362519796254aa84f73acdabc2>> * @lightSyntaxTransform * @nogrep */ @@ -35,7 +35,7 @@ import { FragmentRefs } from "relay-runtime"; import { foo as userFooResolverType } from "../foo"; // Type assertion validating that `userFooResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(userFooResolverType satisfies () => unknown | null | undefined); +(userFooResolverType satisfies () => unknown | null); export type barFragment$data = { readonly foo: ReturnType | null | undefined; readonly " $fragmentType": "barFragment"; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_with_context.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_with_context.expected index 36a93ace3648e..d7c59b8a3e499 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_with_context.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_with_context.expected @@ -24,7 +24,7 @@ type User { name: String } ==================================== OUTPUT =================================== //- __generated__/barFragment.graphql.ts /** - * SignedSource<<7c2c6939d2e5610ed47a154e9cab2dfd>> + * SignedSource<<6b12aceaefe7fa6efecb7c80f51f0430>> * @lightSyntaxTransform * @nogrep */ @@ -42,7 +42,7 @@ import { ITestResolverContextType } from "@test/package"; (userFooResolverType satisfies ( args: undefined, context: ITestResolverContextType, -) => LiveState); +) => LiveState); export type barFragment$data = { readonly foo: ReturnType["read"]> | null | undefined; readonly " $fragmentType": "barFragment"; diff --git a/compiler/crates/relay-typegen/src/flow.rs b/compiler/crates/relay-typegen/src/flow.rs index 695ec4d4c6aa8..8107ddb90d904 100644 --- a/compiler/crates/relay-typegen/src/flow.rs +++ b/compiler/crates/relay-typegen/src/flow.rs @@ -9,6 +9,7 @@ use std::fmt::Result as FmtResult; use std::fmt::Write; use ::intern::string_key::StringKey; +use intern::intern; use itertools::Itertools; use crate::writer::AST; @@ -47,6 +48,7 @@ impl Writer for FlowPrinter { AST::RawType(raw) => write!(&mut self.result, "{}", raw), AST::Union(members) => self.write_union(members), AST::ReadOnlyArray(of_type) => self.write_read_only_array(of_type), + AST::Optional(of_type) => self.write_optional(of_type), AST::Nullable(of_type) => self.write_nullable(of_type), AST::NonNullable(of_type) => self.write_non_nullable(of_type), AST::ExactObject(props) => self.write_object(props, true), @@ -211,7 +213,7 @@ impl FlowPrinter { write!(&mut self.result, ">") } - fn write_nullable(&mut self, of_type: &AST) -> FmtResult { + fn write_optional(&mut self, of_type: &AST) -> FmtResult { write!(&mut self.result, "?")?; match of_type { AST::Union(members) if members.len() > 1 => { @@ -226,6 +228,20 @@ impl FlowPrinter { Ok(()) } + fn write_nullable(&mut self, of_type: &AST) -> FmtResult { + let null_type = AST::RawType(intern!("null")); + if let AST::Union(members) = of_type { + let mut new_members = Vec::with_capacity(members.len() + 1); + new_members.extend_from_slice(members); + new_members.push(null_type); + self.write_union(&new_members)?; + } else { + let members = vec![of_type.clone(), null_type]; + self.write_union(&members)?; + } + Ok(()) + } + fn write_object(&mut self, props: &[Prop], exact: bool) -> FmtResult { if props.is_empty() && exact { write!(&mut self.result, "{{||}}")?; @@ -386,8 +402,6 @@ impl FlowPrinter { #[cfg(test)] mod tests { - use intern::intern; - use super::*; use crate::writer::ExactObject; use crate::writer::InexactObject; @@ -429,12 +443,12 @@ mod tests { #[test] fn nullable_type() { assert_eq!( - print_type(&AST::Nullable(Box::new(AST::String))), + print_type(&AST::Optional(Box::new(AST::String))), "?string".to_string() ); assert_eq!( - print_type(&AST::Nullable(Box::new(AST::Union(SortedASTList::new( + print_type(&AST::Optional(Box::new(AST::Union(SortedASTList::new( vec![AST::String, AST::Number,], ))))), "?(string | number)" diff --git a/compiler/crates/relay-typegen/src/type_selection.rs b/compiler/crates/relay-typegen/src/type_selection.rs index b5cb74dcb819b..aa50da8edad43 100644 --- a/compiler/crates/relay-typegen/src/type_selection.rs +++ b/compiler/crates/relay-typegen/src/type_selection.rs @@ -138,6 +138,7 @@ pub(crate) struct TypeSelectionLinkedField { pub(crate) conditional: bool, pub(crate) concrete_type: Option, pub(crate) is_result_type: bool, + pub(crate) emit_semantic_types: bool, } #[derive(Debug, Clone)] diff --git a/compiler/crates/relay-typegen/src/typescript.rs b/compiler/crates/relay-typegen/src/typescript.rs index 05a2a3c6bb97b..93e3401e0a9d0 100644 --- a/compiler/crates/relay-typegen/src/typescript.rs +++ b/compiler/crates/relay-typegen/src/typescript.rs @@ -61,6 +61,7 @@ impl Writer for TypeScriptPrinter { AST::RawType(raw) => write!(&mut self.result, "{}", raw), AST::Union(members) => self.write_union(members), AST::ReadOnlyArray(of_type) => self.write_read_only_array(of_type), + AST::Optional(of_type) => self.write_optional(of_type), AST::Nullable(of_type) => self.write_nullable(of_type), AST::NonNullable(of_type) => self.write_non_nullable(of_type), AST::ExactObject(object) => self.write_object(object), @@ -216,27 +217,39 @@ impl TypeScriptPrinter { write!(&mut self.result, ">") } - fn write_nullable(&mut self, of_type: &AST) -> FmtResult { + fn write_optional(&mut self, of_type: &AST) -> FmtResult { + if !self.include_undefined_in_nullable_union { + return self.write_nullable(of_type); + } let null_type = AST::RawType(intern!("null")); let undefined_type = AST::RawType(intern!("undefined")); if let AST::Union(members) = of_type { let mut new_members = Vec::with_capacity(members.len() + 1); new_members.extend_from_slice(members); new_members.push(null_type); - if self.include_undefined_in_nullable_union { - new_members.push(undefined_type); - } + new_members.push(undefined_type); self.write_union(&new_members)?; } else { - let mut union_members = vec![of_type.clone(), null_type]; - if self.include_undefined_in_nullable_union { - union_members.push(undefined_type) - } + let union_members = vec![of_type.clone(), null_type, undefined_type]; self.write_union(&union_members)?; } Ok(()) } + fn write_nullable(&mut self, of_type: &AST) -> FmtResult { + let null_type = AST::RawType(intern!("null")); + if let AST::Union(members) = of_type { + let mut new_members = Vec::with_capacity(members.len() + 1); + new_members.extend_from_slice(members); + new_members.push(null_type); + self.write_union(&new_members)?; + } else { + let members = vec![of_type.clone(), null_type]; + self.write_union(&members)?; + } + Ok(()) + } + fn write_object(&mut self, props: &[Prop]) -> FmtResult { if props.is_empty() { write!(&mut self.result, "Record")?; @@ -450,12 +463,12 @@ mod tests { #[test] fn nullable_type() { assert_eq!( - print_type(&AST::Nullable(Box::new(AST::String))), + print_type(&AST::Optional(Box::new(AST::String))), "string | null | undefined".to_string() ); assert_eq!( - print_type(&AST::Nullable(Box::new(AST::Union(SortedASTList::new( + print_type(&AST::Optional(Box::new(AST::Union(SortedASTList::new( vec![AST::String, AST::Number], ))))), "string | number | null | undefined" diff --git a/compiler/crates/relay-typegen/src/visit.rs b/compiler/crates/relay-typegen/src/visit.rs index bf0978b0b1daa..63632254fe71e 100644 --- a/compiler/crates/relay-typegen/src/visit.rs +++ b/compiler/crates/relay-typegen/src/visit.rs @@ -401,7 +401,8 @@ fn generate_resolver_type( ResolverOutputTypeInfo::Legacy => AST::Mixed, }; - let ast = transform_type_reference_into_ast(&schema_field_type, |_| inner_ast); + let can_be_missing = false; // Undefined is not a valid resolver return type + let ast = transform_type_reference_into_ast(&schema_field_type, |_| inner_ast, can_be_missing); let return_type = if resolver_metadata.live { runtime_imports.resolver_live_state_type = true; @@ -727,9 +728,12 @@ fn relay_resolver_field_type( true => field.semantic_type(), false => field.type_.clone(), }; - let inner_value = transform_type_reference_into_ast(&type_, |type_| { - expect_scalar_type(typegen_context, encountered_enums, custom_scalars, type_) - }); + let can_be_missing = !emit_semantic_types; + let inner_value = transform_type_reference_into_ast( + &type_, + |type_| expect_scalar_type(typegen_context, encountered_enums, custom_scalars, type_), + can_be_missing, + ); if required { if type_.is_non_null() { inner_value @@ -756,7 +760,7 @@ fn relay_resolver_field_type( if required || field_type.is_non_null() { AST::NonNullable(Box::new(inner_value)) } else { - AST::Nullable(Box::new(inner_value)) + AST::Optional(Box::new(inner_value)) } } } @@ -908,7 +912,7 @@ fn visit_inline_fragment( type_selections.push(TypeSelection::ScalarField(TypeSelectionScalarField { field_name_or_alias: *FRAGMENT_PROP_NAME, special_field: None, - value: AST::Nullable(Box::new(AST::String)), + value: AST::Optional(Box::new(AST::String)), conditional: false, concrete_type: None, is_result_type: false, @@ -916,7 +920,7 @@ fn visit_inline_fragment( type_selections.push(TypeSelection::ScalarField(TypeSelectionScalarField { field_name_or_alias: *MODULE_COMPONENT, special_field: None, - value: AST::Nullable(Box::new(AST::String)), + value: AST::Optional(Box::new(AST::String)), conditional: false, concrete_type: None, is_result_type: false, @@ -1011,6 +1015,7 @@ fn visit_inline_fragment( conditional: coerce_to_nullable, concrete_type: None, is_result_type, + emit_semantic_types, })] } else { // If the inline fragment is on an abstract type, its selections must be @@ -1090,7 +1095,7 @@ fn visit_actor_change( schema_name, &typegen_context.project_config.schema_config, ), - value: AST::Nullable(Box::new(AST::ActorChangePoint(Box::new( + value: AST::Optional(Box::new(AST::ActorChangePoint(Box::new( selections_to_babel( typegen_context, &field.type_.inner(), @@ -1217,6 +1222,7 @@ fn gen_visit_linked_field( conditional: false, concrete_type: None, is_result_type, + emit_semantic_types, })); } @@ -1282,9 +1288,12 @@ fn visit_scalar_field( } } - let ast = transform_type_reference_into_ast(&field_type, |type_| { - expect_scalar_type(typegen_context, encountered_enums, custom_scalars, type_) - }); + let can_be_missing = !emit_semantic_types; + let ast = transform_type_reference_into_ast( + &field_type, + |type_| expect_scalar_type(typegen_context, encountered_enums, custom_scalars, type_), + can_be_missing, + ); type_selections.push(TypeSelection::ScalarField(TypeSelectionScalarField { field_name_or_alias: key, @@ -1394,7 +1403,7 @@ pub(crate) fn get_data_type( custom_error_import, ); if emit_optional_type { - data_type = AST::Nullable(Box::new(data_type)) + data_type = AST::Optional(Box::new(data_type)) } if emit_plural_type { data_type = AST::ReadOnlyArray(Box::new(data_type)) @@ -1904,8 +1913,11 @@ fn make_prop( custom_error_import, ); - let getter_return_value = - transform_type_reference_into_ast(&linked_field.node_type, |type_| { + // TODO: Is this right? + let can_be_missing = true; + let getter_return_value = transform_type_reference_into_ast( + &linked_field.node_type, + |type_| { return_ast_in_object_case( typegen_context, encountered_enums, @@ -1913,7 +1925,9 @@ fn make_prop( getter_object_props, type_, ) - }); + }, + can_be_missing, + ); let setter_parameter = if just_fragments.is_empty() { if linked_field.node_type.is_list() { @@ -1973,7 +1987,7 @@ fn make_prop( if linked_field.node_type.is_list() { AST::ReadOnlyArray(Box::new(setter_parameter)) } else { - AST::Nullable(Box::new(setter_parameter)) + AST::Optional(Box::new(setter_parameter)) } }; @@ -1995,8 +2009,11 @@ fn make_prop( runtime_imports, custom_error_import, ); - let mut value = - transform_type_reference_into_ast(&linked_field.node_type, |type_| { + + let can_be_missing = !linked_field.emit_semantic_types; + let mut value = transform_type_reference_into_ast( + &linked_field.node_type, + |type_| { return_ast_in_object_case( typegen_context, encountered_enums, @@ -2004,7 +2021,9 @@ fn make_prop( object_props, type_, ) - }); + }, + can_be_missing, + ); if linked_field.is_result_type { value = make_result_type(typegen_context, value); @@ -2110,17 +2129,24 @@ fn raw_response_make_prop( runtime_imports, custom_scalars, ); + // TODO: We probably should't allow mising types in raw responses, + // but that will require a rollout to resolve. + let can_be_missing = true; Prop::KeyValuePair(KeyValuePairProp { key: linked_field.field_name_or_alias, - value: transform_type_reference_into_ast(&node_type, |type_| { - return_ast_in_object_case( - typegen_context, - encountered_enums, - custom_scalars, - object_props, - type_, - ) - }), + value: transform_type_reference_into_ast( + &node_type, + |type_| { + return_ast_in_object_case( + typegen_context, + encountered_enums, + custom_scalars, + object_props, + type_, + ) + }, + can_be_missing, + ), read_only: true, optional, }) @@ -2164,25 +2190,40 @@ fn raw_response_make_prop( fn transform_type_reference_into_ast( type_reference: &TypeReference, transform_inner_type: impl FnOnce(&Type) -> AST, + can_be_missing: bool, ) -> AST { match type_reference { - TypeReference::NonNull(non_null_ref) => { - transform_non_nullable_type_reference_into_ast(non_null_ref, transform_inner_type) - } - _ => AST::Nullable(Box::new(transform_non_nullable_type_reference_into_ast( - type_reference, + TypeReference::NonNull(non_null_ref) => transform_non_nullable_type_reference_into_ast( + non_null_ref, transform_inner_type, - ))), + can_be_missing, + ), + _ => { + if can_be_missing { + AST::Optional(Box::new(transform_non_nullable_type_reference_into_ast( + type_reference, + transform_inner_type, + can_be_missing, + ))) + } else { + AST::Nullable(Box::new(transform_non_nullable_type_reference_into_ast( + type_reference, + transform_inner_type, + can_be_missing, + ))) + } + } } } fn transform_non_nullable_type_reference_into_ast( type_reference: &TypeReference, transform_inner_type: impl FnOnce(&Type) -> AST, + can_be_missing: bool, ) -> AST { match type_reference { TypeReference::List(of_type) => AST::ReadOnlyArray(Box::new( - transform_type_reference_into_ast(of_type, transform_inner_type), + transform_type_reference_into_ast(of_type, transform_inner_type, can_be_missing), )), TypeReference::Named(named_type) => transform_inner_type(named_type), TypeReference::NonNull(_) => panic!("unexpected NonNull"), @@ -2482,7 +2523,7 @@ pub(crate) fn transform_input_type( encountered_enums, custom_scalars, ), - _ => AST::Nullable(Box::new(transform_non_nullable_input_type( + _ => AST::Optional(Box::new(transform_non_nullable_input_type( typegen_context, type_ref, input_object_types, diff --git a/compiler/crates/relay-typegen/src/writer.rs b/compiler/crates/relay-typegen/src/writer.rs index 90ae1efd64bb8..d62e73a9a3398 100644 --- a/compiler/crates/relay-typegen/src/writer.rs +++ b/compiler/crates/relay-typegen/src/writer.rs @@ -28,7 +28,10 @@ use crate::typescript::TypeScriptPrinter; pub enum AST { Union(SortedASTList), ReadOnlyArray(Box), + // Value can also be null Nullable(Box), + // Value can also be null or undefined + Optional(Box), NonNullable(Box), Identifier(StringKey), /// Printed as is, should be valid Flow code. diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-no-arg-nested-linked.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-no-arg-nested-linked.expected index 979ba0566adb4..4b7605f47da49 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-no-arg-nested-linked.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-no-arg-nested-linked.expected @@ -10,8 +10,8 @@ import type { Result } from "relay-runtime"; export type FooQuery$variables = {||}; export type FooQuery$data = {| +me: Result, |}; export type FooQuery = {| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-aliased-inline-fragment.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-aliased-inline-fragment.expected index aded9944fd077..368c7fcccfc1d 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-aliased-inline-fragment.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-aliased-inline-fragment.expected @@ -11,7 +11,7 @@ declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = {| +id: string, +myAlias?: {| - +name: ?string, + +name: string | null, |}, +$fragmentType: MyFragment$fragmentType, |}; diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-mutation.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-mutation.expected index bfa857760d90b..181dc0c13564d 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-mutation.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-mutation.expected @@ -10,11 +10,11 @@ mutation MutationFoo @catch(to: RESULT) { import type { Result } from "relay-runtime"; export type MutationFoo$variables = {||}; export type MutationFoo$data = Result<{| - +unfriend: ?{| - +formerFriend: ?{| - +name: ?string, - |}, - |}, + +unfriend: {| + +formerFriend: {| + +name: string | null, + |} | null, + |} | null, |}, mixed>; export type MutationFoo = {| response: MutationFoo$data, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-root.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-root.expected index 72f53b0280d75..090a5ffba950a 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-root.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-on-root.expected @@ -11,7 +11,7 @@ export type MyQuery$variables = {||}; export type MyQuery$data = {| +me: Result, |}; export type MyQuery = {| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-semantic-non-null-with-catch-to-null.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-semantic-non-null-with-catch-to-null.expected index 73cf7fba6f46a..e69e19aa48af7 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-semantic-non-null-with-catch-to-null.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-semantic-non-null-with-catch-to-null.expected @@ -12,7 +12,7 @@ type ClientUser { import type { FragmentType } from "relay-runtime"; declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = {| - +name: ?string, + +name: string | null, +$fragmentType: MyFragment$fragmentType, |}; export type MyFragment$key = { diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-aliased-inline-fragment.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-aliased-inline-fragment.expected index aa22e72585631..a2550c2da3fce 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-aliased-inline-fragment.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-aliased-inline-fragment.expected @@ -11,7 +11,7 @@ declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = {| +id: string, +myAlias: Result<{| - +name: ?string, + +name: string | null, |}, mixed>, +$fragmentType: MyFragment$fragmentType, |}; diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-fragment.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-fragment.expected index d86c1d857ff4a..aacd6226b4b12 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-fragment.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-fragment.expected @@ -8,7 +8,7 @@ import type { FragmentType } from "relay-runtime"; declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = ?{| +id: string, - +name: ?string, + +name: string | null, +$fragmentType: MyFragment$fragmentType, |}; export type MyFragment$key = { diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-query.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-query.expected index a50b6bb4371d8..2b87c11565553 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-query.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-null-on-query.expected @@ -8,10 +8,10 @@ query MyQuery @catch(to: NULL) { ==================================== OUTPUT =================================== export type MyQuery$variables = {||}; export type MyQuery$data = ?{| - +me: ?{| + +me: {| +id: string, - +name: ?string, - |}, + +name: string | null, + |} | null, |}; export type MyQuery = {| response: MyQuery$data, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-aliased-inline-fragment.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-aliased-inline-fragment.expected index aa22e72585631..a2550c2da3fce 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-aliased-inline-fragment.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-aliased-inline-fragment.expected @@ -11,7 +11,7 @@ declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = {| +id: string, +myAlias: Result<{| - +name: ?string, + +name: string | null, |}, mixed>, +$fragmentType: MyFragment$fragmentType, |}; diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-fragment.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-fragment.expected index a9dd215d414a3..9a76153063a5b 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-fragment.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-fragment.expected @@ -8,7 +8,7 @@ import type { FragmentType, Result } from "relay-runtime"; declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = Result<{| +id: string, - +name: ?string, + +name: string | null, +$fragmentType: MyFragment$fragmentType, |}, mixed>; export type MyFragment$key = { diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-query.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-query.expected index 2a58cbdad9410..17df66f1ff814 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-query.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/catch-to-result-on-query.expected @@ -9,10 +9,10 @@ query MyQuery @catch { import type { Result } from "relay-runtime"; export type MyQuery$variables = {||}; export type MyQuery$data = Result<{| - +me: ?{| + +me: {| +id: string, - +name: ?string, - |}, + +name: string | null, + |} | null, |}, mixed>; export type MyQuery = {| response: MyQuery$data, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-no-fragment.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-no-fragment.expected index 32f198108bde7..8f384d2ee8308 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-no-fragment.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-no-fragment.expected @@ -19,7 +19,7 @@ import type { LiveState } from "relay-runtime"; import userPopStarNameResolverType from "PopStarNameResolver"; // Type assertion validating that `userPopStarNameResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(userPopStarNameResolverType: () => LiveState); +(userPopStarNameResolverType: () => LiveState); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-with-field-args-no-fragment.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-with-field-args-no-fragment.expected index ba73d2e45fd65..30ae987b637c3 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-with-field-args-no-fragment.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-with-field-args-no-fragment.expected @@ -28,7 +28,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; count: ?number, greeting: string, |}, -) => LiveState); +) => LiveState); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-with-field-args.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-with-field-args.expected index 3ebfcc159a796..75fc20d4f2079 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-with-field-args.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver-with-field-args.expected @@ -31,7 +31,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; count: ?number, greeting: string, |}, -) => LiveState); +) => LiveState); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver.expected index 462f24cfabefc..1d3c3f9796b64 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-live-resolver.expected @@ -27,7 +27,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: relayResolver_PopStarNameResolverFragment_name$key, -) => LiveState); +) => LiveState); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-client-edge-required.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-client-edge-required.expected index 77ae5424e8a4b..915278a05a82d 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-client-edge-required.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-client-edge-required.expected @@ -42,9 +42,9 @@ import userBestFriendResolverType from "BestFriendResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userBestFriendResolverType: ( rootKey: relayResolver_BestFriendResolverFragment_name$key, -) => ?{| +) => {| +id: DataID, -|}); +|} | null); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-client-edge.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-client-edge.expected index 587ff3fbee3d9..b66d91f011c2f 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-client-edge.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-client-edge.expected @@ -38,9 +38,9 @@ import userBestFriendResolverType from "BestFriendResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userBestFriendResolverType: ( rootKey: relayResolver_BestFriendResolverFragment_name$key, -) => ?{| +) => {| +id: DataID, -|}); +|} | null); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-in-fragment.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-in-fragment.expected index d727c3adf96bb..d6018a9153c6f 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-in-fragment.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-in-fragment.expected @@ -36,7 +36,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: relayResolver_PopStarNameResolverFragment_name$key, -) => ?mixed); +) => mixed | null); declare export opaque type relayResolver_consumer$fragmentType: FragmentType; export type relayResolver_consumer$data = {| +pop_star_name: ?ReturnType, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-inject-fragment-data.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-inject-fragment-data.expected index 3f1152c1dc7d7..be2336faaf269 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-inject-fragment-data.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-inject-fragment-data.expected @@ -21,7 +21,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( name: relayResolver_PopStarNameResolverFragment_name$data['name'], -) => ?mixed); +) => mixed | null); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-live-client-edge.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-live-client-edge.expected index 10e0840c3eaed..77e194190b348 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-live-client-edge.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-live-client-edge.expected @@ -38,9 +38,9 @@ import userBestFriendResolverType from "BestFriendResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userBestFriendResolverType: ( rootKey: relayResolver_BestFriendResolverFragment_name$key, -) => LiveState LiveState<{| +id: DataID, -|}>); +|} | null>); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-multiple-consumers.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-multiple-consumers.expected index 9024d4afc6f53..a20ca349561ba 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-multiple-consumers.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-multiple-consumers.expected @@ -28,7 +28,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: relayResolver_PopStarNameResolverFragment_name$key, -) => ?mixed); +) => mixed | null); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-named-import.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-named-import.expected index 4bbe5d468b8e8..bfba9de7d5412 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-named-import.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-named-import.expected @@ -26,7 +26,7 @@ import {pop_star_name as userPopStarNameResolverType} from "PopStarNameResolver" // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: relayResolverNamedImport_PopStarNameResolverFragment_name$key, -) => ?mixed); +) => mixed | null); export type relayResolverNamedImport_Query$variables = {||}; export type relayResolverNamedImport_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-client-edge-with-required-edge.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-client-edge-with-required-edge.expected index d011c9721e97b..6501387b24d53 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-client-edge-with-required-edge.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-client-edge-with-required-edge.expected @@ -32,9 +32,9 @@ import userBestFriendsResolverType from "BestFriendResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userBestFriendsResolverType: ( rootKey: relayResolver_BestFriendResolverFragment_name$key, -) => ?$ReadOnlyArray<{| +) => $ReadOnlyArray<{| +id: DataID, -|}>); +|}> | null); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-client-edge.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-client-edge.expected index 74f55feefe7b1..502d78c4dee75 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-client-edge.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-client-edge.expected @@ -32,9 +32,9 @@ import userBestFriendsResolverType from "BestFriendResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userBestFriendsResolverType: ( rootKey: relayResolver_BestFriendResolverFragment_name$key, -) => ?$ReadOnlyArray $ReadOnlyArray<{| +id: DataID, -|}>); +|} | null> | null); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-required-client-edge.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-required-client-edge.expected index 26161ef29372b..5c54949376ac1 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-required-client-edge.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-plural-required-client-edge.expected @@ -32,9 +32,9 @@ import userBestFriendsResolverType from "BestFriendResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userBestFriendsResolverType: ( rootKey: relayResolver_BestFriendResolverFragment_name$key, -) => $ReadOnlyArray $ReadOnlyArray<{| +id: DataID, -|}>); +|} | null>); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-raw-response.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-raw-response.expected index 00cd81ef72abb..5586c207dd771 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-raw-response.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-raw-response.expected @@ -63,7 +63,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: relayResolver_PopStarNameResolverFragment_name$key, -) => ?mixed); +) => mixed | null); declare export opaque type relayResolver_user$fragmentType: FragmentType; export type relayResolver_user$data = {| +pop_star_name: ?ReturnType, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-required.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-required.expected index cadb487e33b50..821ce9d37e0fa 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-required.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-required.expected @@ -25,7 +25,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: relayResolver_PopStarNameResolverFragment_name$key, -) => ?mixed); +) => mixed | null); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-scalar-plural.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-scalar-plural.expected index 0714a76024ea1..e79453875c20e 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-scalar-plural.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-scalar-plural.expected @@ -25,7 +25,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: relayResolver_PopStarNameResolverFragment_name$key, -) => ?$ReadOnlyArray); +) => $ReadOnlyArray | null); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-client-interface.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-client-interface.expected index 272236b150b4e..0e22bf33bf9b2 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-client-interface.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-client-interface.expected @@ -85,7 +85,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: PopStarNameResolverFragment_name$key, -) => ?User__pop_star_name$normalization); +) => User__pop_star_name$normalization | null); declare export opaque type Foo_user$fragmentType: FragmentType; export type Foo_user$data = {| +poppy: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-client-object-plural.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-client-object-plural.expected index 0a3c8df2fd92b..854ac0fe2cf9c 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-client-object-plural.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-client-object-plural.expected @@ -47,7 +47,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: PopStarNameResolverFragment_name$key, -) => ?$ReadOnlyArray); +) => $ReadOnlyArray | null); declare export opaque type Foo_user$fragmentType: FragmentType; export type Foo_user$data = {| +poppy: ?$ReadOnlyArray ?User__pop_star_name$normalization); +) => User__pop_star_name$normalization | null); declare export opaque type Foo_user$fragmentType: FragmentType; export type Foo_user$data = {| +poppy: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-enum-plural.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-enum-plural.expected index 96b15fee7cb84..0bdfd943633f8 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-enum-plural.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-enum-plural.expected @@ -32,7 +32,7 @@ import userPopStarNamesResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNamesResolverType: ( rootKey: PopStarNameResolverFragment_name$key, -) => ?$ReadOnlyArray); +) => $ReadOnlyArray | null); declare export opaque type Foo_user$fragmentType: FragmentType; export type Foo_user$data = {| +poppy: ?$ReadOnlyArray, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-enum.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-enum.expected index 82d11605b8a01..836fba90d4310 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-enum.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-enum.expected @@ -27,7 +27,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: PopStarNameResolverFragment_name$key, -) => ?TestEnums); +) => TestEnums | null); declare export opaque type Foo_user$fragmentType: FragmentType; export type Foo_user$data = {| +poppy: ?TestEnums, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value-plural.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value-plural.expected index 97261490cb0a7..1010e13f86008 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value-plural.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value-plural.expected @@ -31,7 +31,7 @@ import userPopStarNamesResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNamesResolverType: ( rootKey: PopStarNameResolverFragment_name$key, -) => ?$ReadOnlyArray); +) => $ReadOnlyArray | null); declare export opaque type Foo_user$fragmentType: FragmentType; export type Foo_user$data = {| +poppy: ?ReturnType, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value-required.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value-required.expected index 3d970186cc8db..8ce1e03863096 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value-required.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value-required.expected @@ -26,7 +26,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: PopStarNameResolverFragment_name$key, -) => ?mixed); +) => mixed | null); declare export opaque type Foo_user$fragmentType: FragmentType; export type Foo_user$data = {| +poppy: $NonMaybeType>, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value.expected index eb2432c4cdb80..e1167e5e42c1a 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-relay-resolver-value.expected @@ -26,7 +26,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: PopStarNameResolverFragment_name$key, -) => ?mixed); +) => mixed | null); declare export opaque type Foo_user$fragmentType: FragmentType; export type Foo_user$data = {| +poppy: ?ReturnType, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar-plural.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar-plural.expected index 3a47195d2d21a..f6d20f97921f2 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar-plural.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar-plural.expected @@ -31,7 +31,7 @@ import userPopStarNamesResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNamesResolverType: ( rootKey: PopStarNameResolverFragment_name$key, -) => ?$ReadOnlyArray); +) => $ReadOnlyArray | null); declare export opaque type Foo_user$fragmentType: FragmentType; export type Foo_user$data = {| +poppy: ?$ReadOnlyArray, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar-required.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar-required.expected index 25b2ec42bedd4..b44eb64cdb17a 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar-required.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar-required.expected @@ -26,7 +26,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: PopStarNameResolverFragment_name$key, -) => ?string); +) => string | null); declare export opaque type Foo_user$fragmentType: FragmentType; export type Foo_user$data = {| +poppy: $NonMaybeType, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar.expected index c587aee44ff9a..57bb1410d87cc 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver-with-output-type-scalar.expected @@ -26,7 +26,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: PopStarNameResolverFragment_name$key, -) => ?string); +) => string | null); declare export opaque type Foo_user$fragmentType: FragmentType; export type Foo_user$data = {| +poppy: ?string, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver.expected index 078036327e151..fd303b4f3b660 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/relay-resolver.expected @@ -25,7 +25,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType: ( rootKey: relayResolver_PopStarNameResolverFragment_name$key, -) => ?mixed); +) => mixed | null); export type relayResolver_Query$variables = {||}; export type relayResolver_Query$data = {| +me: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type-with-extension.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type-with-extension.expected index a951ddfb5cda1..ec6a1177b5dbd 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type-with-extension.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type-with-extension.expected @@ -28,7 +28,7 @@ import catDescriptionResolverType from "CatResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (catDescriptionResolverType: ( model: Tabby____relay_model_instance$data['__relay_model_instance'], -) => ?mixed); +) => mixed | null); declare export opaque type resolverOnInterfaceOfAllStrongModelTypeWithExtensionFragment$fragmentType: FragmentType; export type resolverOnInterfaceOfAllStrongModelTypeWithExtensionFragment$data = {| +description: ?ReturnType, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type-with-root-fragment.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type-with-root-fragment.expected index 072eca9fb431e..14a0c05f83080 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type-with-root-fragment.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type-with-root-fragment.expected @@ -30,7 +30,7 @@ import catDescriptionResolverType from "CatResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (catDescriptionResolverType: ( rootKey: description_Fragment$key, -) => ?mixed); +) => mixed | null); declare export opaque type description_Fragment$fragmentType: FragmentType; export type description_Fragment$data = {| +description: ?ReturnType, @@ -49,7 +49,7 @@ import catDescriptionResolverType from "CatResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (catDescriptionResolverType: ( rootKey: description_Fragment$key, -) => ?mixed); +) => mixed | null); declare export opaque type resolverOnInterfaceOfAllStrongModelTypeWithRootFragment$fragmentType: FragmentType; export type resolverOnInterfaceOfAllStrongModelTypeWithRootFragment$data = {| +description: ?ReturnType, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type.expected index 270ea7438b8ad..f9bfca31edc22 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-strong-model-type.expected @@ -30,7 +30,7 @@ import catDescriptionResolverType from "CatResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (catDescriptionResolverType: ( model: Persian____relay_model_instance$data['__relay_model_instance'] | Tabby____relay_model_instance$data['__relay_model_instance'], -) => ?mixed); +) => mixed | null); declare export opaque type resolverOnInterfaceOfAllStrongModelTypeFragment$fragmentType: FragmentType; export type resolverOnInterfaceOfAllStrongModelTypeFragment$data = {| +description: ?ReturnType, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-weak-model-type.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-weak-model-type.expected index a9c8504ec1c95..ecc4b395b20e0 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-weak-model-type.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/resolver-on-interface-of-all-weak-model-type.expected @@ -27,7 +27,7 @@ import catDescriptionResolverType from "CatResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (catDescriptionResolverType: ( model: Persian____relay_model_instance$data['__relay_model_instance'] | Tabby____relay_model_instance$data['__relay_model_instance'], -) => ?mixed); +) => mixed | null); declare export opaque type resolverOnInterfaceOfAllWeakModelTypeFragment$fragmentType: FragmentType; export type resolverOnInterfaceOfAllWeakModelTypeFragment$data = {| +description: ?ReturnType, diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_in_raw_response.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_in_raw_response.expected index 096130def163f..7e80d0086cdea 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_in_raw_response.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_in_raw_response.expected @@ -15,17 +15,17 @@ query MyQuery @raw_response_type @throwOnFieldError { ==================================== OUTPUT =================================== export type MyQuery$variables = {||}; export type MyQuery$data = {| - +opera: ?{| + +opera: {| +cast: $ReadOnlyArray<{| +character: string, +singer: {| - +name: ?string, + +name: string | null, |}, |}>, +composer: {| - +name: ?string, + +name: string | null, |}, - |}, + |} | null, |}; export type MyQuery$rawResponse = {| +opera?: ?{| diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_items_in_matrix.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_items_in_matrix.expected index 9ae752615eba5..9ca56e6691461 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_items_in_matrix.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_items_in_matrix.expected @@ -12,7 +12,7 @@ type Screen { import type { FragmentType } from "relay-runtime"; declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = {| - +pixels: ?$ReadOnlyArray>, + +pixels: $ReadOnlyArray<$ReadOnlyArray | null> | null, +$fragmentType: MyFragment$fragmentType, |}; export type MyFragment$key = { diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_liked_field_resolver.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_liked_field_resolver.expected index b010ceeb06d4b..d6c8a7fdd5082 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_liked_field_resolver.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_liked_field_resolver.expected @@ -37,7 +37,7 @@ import clientUserBestFriendResolverType from "bar"; declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = {| +best_friend: {| - +name: ?string, + +name: string | null, |}, +$fragmentType: MyFragment$fragmentType, |}; diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_liked_field_weak_resolver.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_liked_field_weak_resolver.expected index 0cb105fa5368b..c787ab0196599 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_liked_field_weak_resolver.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_liked_field_weak_resolver.expected @@ -36,7 +36,7 @@ import clientUserBlobResolverType from "bar"; declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = {| +blob: {| - +data: ?string, + +data: string | null, |}, +$fragmentType: MyFragment$fragmentType, |}; diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_linked_field.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_linked_field.expected index 9591a5bd78223..d54f0c9d79ab7 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_linked_field.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_linked_field.expected @@ -15,7 +15,7 @@ import type { FragmentType } from "relay-runtime"; declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = {| +best_friend: {| - +name: ?string, + +name: string | null, |}, +$fragmentType: MyFragment$fragmentType, |}; diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_list_item.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_list_item.expected index 5016313160470..61a1ce0482cdb 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_list_item.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_non_null_list_item.expected @@ -12,7 +12,7 @@ type ClientUser { import type { FragmentType } from "relay-runtime"; declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = {| - +favorite_numbers: ?$ReadOnlyArray, + +favorite_numbers: $ReadOnlyArray | null, +$fragmentType: MyFragment$fragmentType, |}; export type MyFragment$key = { diff --git a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_null_required_throw_on_error.expected b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_null_required_throw_on_error.expected index 2031e76790b80..c8677d3e0f998 100644 --- a/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_null_required_throw_on_error.expected +++ b/compiler/crates/relay-typegen/tests/generate_flow/fixtures/semantic_null_required_throw_on_error.expected @@ -15,7 +15,7 @@ import type { FragmentType } from "relay-runtime"; import clientUserResolverNameResolverType from "CatResolver"; // Type assertion validating that `clientUserResolverNameResolverType` resolver is correctly implemented. // A type error here indicates that the type signature of the resolver module is incorrect. -(clientUserResolverNameResolverType: () => ?mixed); +(clientUserResolverNameResolverType: () => mixed | null); declare export opaque type MyFragment$fragmentType: FragmentType; export type MyFragment$data = ?{| +nullable_name: string, diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/catch-no-arg-nested-linked.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/catch-no-arg-nested-linked.expected index 8767cce202c33..e5af81b618f72 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/catch-no-arg-nested-linked.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/catch-no-arg-nested-linked.expected @@ -10,8 +10,8 @@ import { Result } from "relay-runtime"; export type FooQuery$variables = Record; export type FooQuery$data = { readonly me: Result<{ - readonly firstName: string | null | undefined; - readonly lastName: string | null | undefined; + readonly firstName: string | null; + readonly lastName: string | null; } | null | undefined, unknown>; }; export type FooQuery = { diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/catch-semantic-non-null-with-catch-to-null.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/catch-semantic-non-null-with-catch-to-null.expected index 7853cd801808b..222598f07370a 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/catch-semantic-non-null-with-catch-to-null.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/catch-semantic-non-null-with-catch-to-null.expected @@ -11,7 +11,7 @@ type ClientUser { ==================================== OUTPUT =================================== import { FragmentRefs } from "relay-runtime"; export type MyFragment$data = { - readonly name: string | null | undefined; + readonly name: string | null; readonly " $fragmentType": "MyFragment"; }; export type MyFragment$key = { diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/linked-semantic-non-null-with-catch.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/linked-semantic-non-null-with-catch.expected index 5a2fc05b30f43..57a31843e4a71 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/linked-semantic-non-null-with-catch.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/linked-semantic-non-null-with-catch.expected @@ -15,7 +15,7 @@ extend type Query { import { FragmentRefs, Result } from "relay-runtime"; export type MyFragment$data = { readonly my_user: Result<{ - readonly name: string | null | undefined; + readonly name: string | null; }, unknown>; readonly " $fragmentType": "MyFragment"; }; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-on-query-with-output-type.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-on-query-with-output-type.expected index ef682bea0927d..967687b32abae 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-on-query-with-output-type.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-on-query-with-output-type.expected @@ -28,7 +28,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType satisfies ( rootKey: PopStarNameResolverFragment_name$key, -) => unknown | null | undefined); +) => unknown | null); export type Foo_user$variables = Record; export type Foo_user$data = { readonly me: { diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-client-interface.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-client-interface.expected index 6b0824de8d315..8148256109612 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-client-interface.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-client-interface.expected @@ -73,7 +73,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType satisfies ( rootKey: PopStarNameResolverFragment_name$key, -) => User__pop_star_name$normalization | null | undefined); +) => User__pop_star_name$normalization | null); export type Foo_user$data = { readonly poppy: { readonly name: string | null | undefined; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-client-object.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-client-object.expected index 156591332c0e7..a4c2b5e74f6ee 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-client-object.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-client-object.expected @@ -42,7 +42,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType satisfies ( rootKey: PopStarNameResolverFragment_name$key, -) => User__pop_star_name$normalization | null | undefined); +) => User__pop_star_name$normalization | null); export type Foo_user$data = { readonly poppy: { readonly name: string | null | undefined; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-relay-resolver-value-required.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-relay-resolver-value-required.expected index c67cc64761452..b7fb79a94cd74 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-relay-resolver-value-required.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-relay-resolver-value-required.expected @@ -25,7 +25,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType satisfies ( rootKey: PopStarNameResolverFragment_name$key, -) => unknown | null | undefined); +) => unknown | null); export type Foo_user$data = { readonly poppy: NonNullable>; readonly " $fragmentType": "Foo_user"; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-relay-resolver-value.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-relay-resolver-value.expected index fc7174d94a82c..5c705bb7edf03 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-relay-resolver-value.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/relay-resolver-with-output-type-relay-resolver-value.expected @@ -25,7 +25,7 @@ import userPopStarNameResolverType from "PopStarNameResolver"; // A type error here indicates that the type signature of the resolver module is incorrect. (userPopStarNameResolverType satisfies ( rootKey: PopStarNameResolverFragment_name$key, -) => unknown | null | undefined); +) => unknown | null); export type Foo_user$data = { readonly poppy: ReturnType | null | undefined; readonly " $fragmentType": "Foo_user"; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic-non-null-deeply-nested-within-catch.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic-non-null-deeply-nested-within-catch.expected index 23dd1502eac48..c8d324ee31f65 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic-non-null-deeply-nested-within-catch.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic-non-null-deeply-nested-within-catch.expected @@ -23,7 +23,7 @@ export type MyFragment$data = { readonly me: { readonly clientUser: { readonly name: string; - } | null | undefined; + } | null; } | null | undefined; readonly " $fragmentType": "MyFragment"; }; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_in_raw_response.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_in_raw_response.expected index d531b42780369..4ee3e0bfc01a3 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_in_raw_response.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_in_raw_response.expected @@ -19,13 +19,13 @@ export type MyQuery$data = { readonly cast: ReadonlyArray<{ readonly character: string; readonly singer: { - readonly name: string | null | undefined; + readonly name: string | null; }; }>; readonly composer: { - readonly name: string | null | undefined; + readonly name: string | null; }; - } | null | undefined; + } | null; }; export type MyQuery$rawResponse = { readonly opera?: { diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_items_in_matrix.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_items_in_matrix.expected index f66c1769aa364..38c9e3469b067 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_items_in_matrix.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_items_in_matrix.expected @@ -11,7 +11,7 @@ type Screen { ==================================== OUTPUT =================================== import { FragmentRefs } from "relay-runtime"; export type MyFragment$data = { - readonly pixels: ReadonlyArray | null | undefined> | null | undefined; + readonly pixels: ReadonlyArray | null> | null; readonly " $fragmentType": "MyFragment"; }; export type MyFragment$key = { diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_liked_field_resolver.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_liked_field_resolver.expected index b2d579a3aa371..f06f3b0d3ac46 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_liked_field_resolver.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_liked_field_resolver.expected @@ -36,7 +36,7 @@ import clientUserBestFriendResolverType from "bar"; }); export type MyFragment$data = { readonly best_friend: { - readonly name: string | null | undefined; + readonly name: string | null; }; readonly " $fragmentType": "MyFragment"; }; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_liked_field_weak_resolver.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_liked_field_weak_resolver.expected index 60c20e53d3286..bb511b99d5b02 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_liked_field_weak_resolver.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_liked_field_weak_resolver.expected @@ -34,7 +34,7 @@ import clientUserBlobResolverType from "bar"; (clientUserBlobResolverType satisfies () => ClientUser__blob$normalization); export type MyFragment$data = { readonly blob: { - readonly data: string | null | undefined; + readonly data: string | null; }; readonly " $fragmentType": "MyFragment"; }; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_linked_field.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_linked_field.expected index 6eccf5559059c..34f46cf3b56e3 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_linked_field.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_linked_field.expected @@ -14,7 +14,7 @@ type ClientUser { import { FragmentRefs } from "relay-runtime"; export type MyFragment$data = { readonly best_friend: { - readonly name: string | null | undefined; + readonly name: string | null; }; readonly " $fragmentType": "MyFragment"; }; diff --git a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_list_item.expected b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_list_item.expected index 7baf4f099bfd9..cea9b310512aa 100644 --- a/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_list_item.expected +++ b/compiler/crates/relay-typegen/tests/generate_typescript/fixtures/semantic_non_null_list_item.expected @@ -11,7 +11,7 @@ type ClientUser { ==================================== OUTPUT =================================== import { FragmentRefs } from "relay-runtime"; export type MyFragment$data = { - readonly favorite_numbers: ReadonlyArray | null | undefined; + readonly favorite_numbers: ReadonlyArray | null; readonly " $fragmentType": "MyFragment"; }; export type MyFragment$key = {