From 3e1d7cdfe3a9d4810a28127eb4790632338c0c5a Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Tue, 23 Jul 2024 11:12:01 -0700 Subject: [PATCH 01/16] remove ts-nocheck --- .../crates/relay-compiler/src/artifact_content/content.rs | 1 - .../fixtures/fragment_arguments.expected | 6 ++---- .../fixtures/preloadable_query_typescript.expected | 6 ++---- .../fixtures/simple_fragment.expected | 3 +-- .../fixtures/typescript_resolver_type_import.expected | 3 +-- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/compiler/crates/relay-compiler/src/artifact_content/content.rs b/compiler/crates/relay-compiler/src/artifact_content/content.rs index a3f49b408a2fa..9e059a10910ce 100644 --- a/compiler/crates/relay-compiler/src/artifact_content/content.rs +++ b/compiler/crates/relay-compiler/src/artifact_content/content.rs @@ -894,7 +894,6 @@ fn generate_disable_lint_section(language: &TypegenLanguage) -> Result { writeln!(section, "/* tslint:disable */")?; writeln!(section, "/* eslint-disable */")?; - writeln!(section, "// @ts-nocheck")?; } TypegenLanguage::Flow | TypegenLanguage::JavaScript => { writeln!(section, "/* eslint-disable */")?; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected index f7281490fa873..236c0ed1102b1 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected @@ -39,14 +39,13 @@ type Post { ==================================== OUTPUT =================================== //- __generated__/foo.graphql.ts /** - * SignedSource<<0e503f5c200310a5580a2b4853a499ce>> + * SignedSource<<7ff63745b7dbb2c82d5d1c126c4eba41>> * @lightSyntaxTransform * @nogrep */ /* tslint:disable */ /* eslint-disable */ -// @ts-nocheck import { Fragment, ReaderFragment } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; @@ -108,14 +107,13 @@ export default node; //- __generated__/fooQuery.graphql.ts /** - * SignedSource<<20043d1d00f946a33727d27907f7f3f2>> + * SignedSource<<3e1d059e8950880fb479c660ec7469a5>> * @lightSyntaxTransform * @nogrep */ /* tslint:disable */ /* eslint-disable */ -// @ts-nocheck import { ConcreteRequest, Query } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected index e5fe00c999739..a705d3e3783d3 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected @@ -23,7 +23,7 @@ type Query { userName: String } ==================================== OUTPUT =================================== //- __generated__/fooQuery$parameters.ts /** - * SignedSource<<7de8baf3626a3ece606b72c2ece21848>> + * SignedSource<> * @relayHash ae6874c86ce5db2df8d6b253a6a0ec13 * @lightSyntaxTransform * @nogrep @@ -31,7 +31,6 @@ type Query { userName: String } /* tslint:disable */ /* eslint-disable */ -// @ts-nocheck // @relayRequestID ae6874c86ce5db2df8d6b253a6a0ec13 @@ -53,7 +52,7 @@ export default node; //- __generated__/fooQuery.graphql.ts /** - * SignedSource<<461989c03655ebfecf253b741f65ef91>> + * SignedSource<> * @relayHash ae6874c86ce5db2df8d6b253a6a0ec13 * @lightSyntaxTransform * @nogrep @@ -61,7 +60,6 @@ export default node; /* tslint:disable */ /* eslint-disable */ -// @ts-nocheck // @relayRequestID ae6874c86ce5db2df8d6b253a6a0ec13 diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected index 67dd12c461485..7eeea50ebb21e 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected @@ -17,14 +17,13 @@ type User { name: String } ==================================== OUTPUT =================================== //- __generated__/foo.graphql.ts /** - * SignedSource<> + * SignedSource<> * @lightSyntaxTransform * @nogrep */ /* tslint:disable */ /* eslint-disable */ -// @ts-nocheck import { Fragment, ReaderFragment } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; 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 e8c1d60403663..346b0b4ba1385 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 @@ -25,14 +25,13 @@ type User { name: String } ==================================== OUTPUT =================================== //- __generated__/barFragment.graphql.ts /** - * SignedSource<<6c58dff465555ee63fe212edde3a3e01>> + * SignedSource<> * @lightSyntaxTransform * @nogrep */ /* tslint:disable */ /* eslint-disable */ -// @ts-nocheck import { Fragment, ReaderFragment } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; From d2cb00bcc699dd0ab059598c328e4476a6fd63cc Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 24 Jul 2024 11:37:21 -0700 Subject: [PATCH 02/16] fix: remove extraneous import --- .../src/build_project/artifact_generated_types.rs | 10 +++++----- .../fixtures/client_mutation_extension.expected | 4 ++-- .../fixtures/client_mutation_resolver.expected | 4 ++-- ...nt_mutation_resolver_different_mutation_ok.expected | 4 ++-- ...ema_extension_interface_uses_resolver_type.expected | 4 ++-- ...tom_scalar_variable_default_arg_non_strict.expected | 4 ++-- .../fixtures/error_handling_query.expected | 4 ++-- .../fixtures/fragment_arguments.expected | 4 ++-- ...vers_on_interface_of_all_strong_model_type.expected | 4 ++-- ...eturns_interfaces_of_all_strong_model_type.expected | 4 ++-- .../fixtures/preloadable_query_flow.expected | 4 ++-- .../fixtures/preloadable_query_typescript.expected | 4 ++-- ...r_returns_interface_of_all_live_model_type.expected | 4 ++-- ...returns_interface_of_all_strong_model_type.expected | 4 ++-- ...ace_of_all_strong_model_type_including_cse.expected | 4 ++-- ...r_returns_interface_of_all_weak_model_type.expected | 4 ++-- ...ace_of_live_and_non_live_strong_model_type.expected | 4 ++-- ...d_interface_fragment_on_weak_concrete_type.expected | 4 ++-- 18 files changed, 39 insertions(+), 39 deletions(-) diff --git a/compiler/crates/relay-compiler/src/build_project/artifact_generated_types.rs b/compiler/crates/relay-compiler/src/build_project/artifact_generated_types.rs index 3152d2eb87bcc..6a395b51d6f19 100644 --- a/compiler/crates/relay-compiler/src/build_project/artifact_generated_types.rs +++ b/compiler/crates/relay-compiler/src/build_project/artifact_generated_types.rs @@ -38,21 +38,21 @@ impl ArtifactGeneratedTypes { let (kind, imported_types) = match operation.kind { OperationKind::Query => { if is_client_only { - ("ClientQuery", "ClientRequest, ClientQuery") + ("ClientQuery", "ClientRequest") } else { - ("Query", "ConcreteRequest, Query") + ("Query", "ConcreteRequest") } } OperationKind::Mutation => { if is_client_only { - ("Mutation", "ClientRequest, Mutation") + ("Mutation", "ClientRequest") } else { - ("Mutation", "ConcreteRequest, Mutation") + ("Mutation", "ConcreteRequest") } } OperationKind::Subscription => ( "GraphQLSubscription", - "ConcreteRequest, GraphQLSubscription", + "ConcreteRequest", ), }; let exported_type = if has_raw_response_type_directive(operation) { diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_extension.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_extension.expected index a8ff79add864b..bf0cf6ee4cfd1 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_extension.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_extension.expected @@ -35,7 +35,7 @@ extend type Mutation { ==================================== OUTPUT =================================== //- __generated__/barMutation.graphql.js /** - * SignedSource<<8c2ec235b8b068c2c2fffbc3aae787b8>> + * SignedSource<<7b66b8b44ae4d0d2a0f5b850cd52853c>> * @flow * @lightSyntaxTransform * @nogrep @@ -46,7 +46,7 @@ extend type Mutation { 'use strict'; /*:: -import type { ClientRequest, Mutation } from 'relay-runtime'; +import type { ClientRequest } from 'relay-runtime'; 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.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_resolver.expected index 3e9340a126d26..9c75d0fd8b1be 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 @@ -32,7 +32,7 @@ type Query { ==================================== OUTPUT =================================== //- __generated__/barMutation.graphql.js /** - * SignedSource<<7f1de50339842bab9cecc72c6fbc076f>> + * SignedSource<<538b86eea851f38c2187170367298cc2>> * @flow * @lightSyntaxTransform * @nogrep @@ -43,7 +43,7 @@ type Query { 'use strict'; /*:: -import type { ClientRequest, Mutation } from 'relay-runtime'; +import type { ClientRequest } 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. 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 3b3c2e0363ed3..cca6f34a3eb48 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 @@ -106,7 +106,7 @@ export default node; //- __generated__/barMutation.graphql.js /** - * SignedSource<<6f79ca8d7718498c480388c5b22a5130>> + * SignedSource<<3e41ed0b1d0494106fb3c72b23df5d64>> * @flow * @lightSyntaxTransform * @nogrep @@ -117,7 +117,7 @@ export default node; 'use strict'; /*:: -import type { ClientRequest, Mutation } from 'relay-runtime'; +import type { ClientRequest } 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. 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 f4457c7de0df3..1882dfcb839a9 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 @@ -175,7 +175,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<<678979a6fbd285c60deb8d498debb4ca>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -186,7 +186,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { ClientRequest } from 'relay-runtime'; import type { DataID } from "relay-runtime"; import type { Admin____relay_model_instance$data } from "Admin____relay_model_instance.graphql"; import {admin as adminAdminResolverType} from "Admin"; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/custom_scalar_variable_default_arg_non_strict.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/custom_scalar_variable_default_arg_non_strict.expected index 6c8a54a3a86f1..17a3a1bd3532d 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/custom_scalar_variable_default_arg_non_strict.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/custom_scalar_variable_default_arg_non_strict.expected @@ -46,7 +46,7 @@ extend type Query { ==================================== OUTPUT =================================== //- __generated__/fooCustomScalarLiteralArgQuery.graphql.js /** - * SignedSource<<27b4bcb541cbdf999e094b271c6bf062>> + * SignedSource<<4f380cead53a51a6c7fb435684020240>> * @flow * @lightSyntaxTransform * @nogrep @@ -57,7 +57,7 @@ extend type Query { 'use strict'; /*:: -import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { ClientRequest } from 'relay-runtime'; export type fooCustomScalarLiteralArgQuery$variables = {| arg: any, arg_server: any, 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 41accfb2e2041..f16d16753b498 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 @@ -20,7 +20,7 @@ type User { name: String } ==================================== OUTPUT =================================== //- __generated__/fooQuery.graphql.js /** - * SignedSource<<3fedea69ae18a5e38707e31bf973e7af>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -31,7 +31,7 @@ type User { name: String } 'use strict'; /*:: -import type { ConcreteRequest, Query } from 'relay-runtime'; +import type { ConcreteRequest } from 'relay-runtime'; export type fooQuery$variables = {||}; export type fooQuery$data = {| +me: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected index 236c0ed1102b1..7271e2a60868e 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected @@ -107,7 +107,7 @@ export default node; //- __generated__/fooQuery.graphql.ts /** - * SignedSource<<3e1d059e8950880fb479c660ec7469a5>> + * SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -115,7 +115,7 @@ export default node; /* tslint:disable */ /* eslint-disable */ -import { ConcreteRequest, Query } from 'relay-runtime'; +import { ConcreteRequest } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; export type fooQuery$variables = Record; export type fooQuery$data = { 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 dc843e65f444c..bbef7a7605f74 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 @@ -180,7 +180,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -191,7 +191,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { ClientRequest } from 'relay-runtime'; import type { Admin____relay_model_instance$data } from "Admin____relay_model_instance.graphql"; import type { User____relay_model_instance$data } from "User____relay_model_instance.graphql"; import {description as iActorDescriptionResolverType} from "IActorResolvers"; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_returns_interfaces_of_all_strong_model_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_returns_interfaces_of_all_strong_model_type.expected index 52096b0c891a6..301539a0c2f92 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_returns_interfaces_of_all_strong_model_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_returns_interfaces_of_all_strong_model_type.expected @@ -189,7 +189,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<> + * SignedSource<<494b069860d15292419ea8b7b0af858e>> * @flow * @lightSyntaxTransform * @nogrep @@ -200,7 +200,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { ClientRequest } from 'relay-runtime'; export type PersonComponentQuery$variables = {||}; export type PersonComponentQuery$data = {| +actor: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_flow.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_flow.expected index 2b08a3cf1f33a..d934489eb55ae 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_flow.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_flow.expected @@ -56,7 +56,7 @@ export default ((node/*: any*/)/*: PreloadableConcreteRequest*/); //- __generated__/fooQuery.graphql.js /** - * SignedSource<<8cc7b8c559f66dd65618447b4688e2e9>> + * SignedSource<<8f17045eff339b57b74e875045b0f6c3>> * @relayHash ae6874c86ce5db2df8d6b253a6a0ec13 * @flow * @lightSyntaxTransform @@ -70,7 +70,7 @@ export default ((node/*: any*/)/*: PreloadableConcreteRequest*/); // @relayRequestID ae6874c86ce5db2df8d6b253a6a0ec13 /*:: -import type { ConcreteRequest, Query } from 'relay-runtime'; +import type { ConcreteRequest } from 'relay-runtime'; export type fooQuery$variables = {||}; export type fooQuery$data = {| +userName: ?string, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected index a705d3e3783d3..30c490afdb026 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected @@ -52,7 +52,7 @@ export default node; //- __generated__/fooQuery.graphql.ts /** - * SignedSource<> + * SignedSource<<09465a6feb3ad10a80c2e0606387a0e3>> * @relayHash ae6874c86ce5db2df8d6b253a6a0ec13 * @lightSyntaxTransform * @nogrep @@ -63,7 +63,7 @@ export default node; // @relayRequestID ae6874c86ce5db2df8d6b253a6a0ec13 -import { ConcreteRequest, Query } from 'relay-runtime'; +import { ConcreteRequest } from 'relay-runtime'; export type fooQuery$variables = Record; export type fooQuery$data = { readonly userName: string | null | undefined; 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 8b835fb6b7816..15f98cd259ee3 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 @@ -177,7 +177,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/QueryComponentQuery.graphql.js /** - * SignedSource<<750533be4ec90cc3f3f7cccb2bf849f4>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -188,7 +188,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { ClientRequest } from 'relay-runtime'; import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. 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 a6f29d6814161..a79e73bd96bf1 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 @@ -175,7 +175,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -186,7 +186,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { ClientRequest } from 'relay-runtime'; import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. 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 5f57d66d7fb92..7d84a92d58829 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 @@ -180,7 +180,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<> + * SignedSource<<28018d85e2942283fbdb6c0b99ca8481>> * @flow * @lightSyntaxTransform * @nogrep @@ -191,7 +191,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { ClientRequest } from 'relay-runtime'; import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. 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 9bd31eda8ea03..1e864119541ae 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 @@ -114,7 +114,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/QueryComponentQuery.graphql.js /** - * SignedSource<<4c12cb9f690c4ba88d309a8e9f747867>> + * SignedSource<<292d01f3881655a68a78fe0b6eff9b9e>> * @flow * @lightSyntaxTransform * @nogrep @@ -125,7 +125,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { ClientRequest } 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. 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 796a41100c23e..7b4232ffdd01b 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 @@ -176,7 +176,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/QueryComponentQuery.graphql.js /** - * SignedSource<> + * SignedSource<<8525ec6ab2fa67c5c8f78ebe5e4edd11>> * @flow * @lightSyntaxTransform * @nogrep @@ -187,7 +187,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { ClientRequest } from 'relay-runtime'; import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. 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 fa1d63a33ce10..c4df6d7e3b088 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 @@ -211,7 +211,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/UserQueryComponentQuery.graphql.js /** - * SignedSource<<097b4c59a2a87918f0d913802fcac7cb>> + * SignedSource<<6fd845898f7b83c97be6ad0c585178c0>> * @flow * @lightSyntaxTransform * @nogrep @@ -222,7 +222,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest, ClientQuery } from 'relay-runtime'; +import type { ClientRequest } from 'relay-runtime'; import type { PersonComponentFragment$fragmentType } from "PersonComponentFragment.graphql"; import {user as queryUserResolverType} from "UserTypeResolvers"; // Type assertion validating that `queryUserResolverType` resolver is correctly implemented. From 3cad5043867b6d61de8fb18dcf2e6a9ccac0819b Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 24 Jul 2024 14:12:48 -0700 Subject: [PATCH 03/16] add typegen config --- compiler/Cargo.lock | 1 - .../src/artifact_content/content.rs | 21 +++++++++++-------- .../compile_relay_artifacts_with_custom_id.rs | 5 +++++ .../fixtures/fragment_arguments.expected | 3 ++- .../fixtures/fragment_arguments.input | 3 ++- .../preloadable_query_typescript.expected | 3 ++- .../preloadable_query_typescript.input | 3 ++- .../fixtures/simple_fragment.expected | 3 ++- .../fixtures/simple_fragment.input | 3 ++- .../typescript_resolver_type_import.expected | 3 ++- .../typescript_resolver_type_import.input | 3 ++- .../crates/relay-config/src/typegen_config.rs | 5 +++++ 12 files changed, 38 insertions(+), 18 deletions(-) diff --git a/compiler/Cargo.lock b/compiler/Cargo.lock index 5787502a5e864..d55879a86ac9d 100644 --- a/compiler/Cargo.lock +++ b/compiler/Cargo.lock @@ -429,7 +429,6 @@ dependencies = [ "graphql-ir", "graphql-syntax", "intern", - "relay-config", "relay-test-schema", "relay-transforms", "rustc-hash", diff --git a/compiler/crates/relay-compiler/src/artifact_content/content.rs b/compiler/crates/relay-compiler/src/artifact_content/content.rs index 9e059a10910ce..9dec3d620d64e 100644 --- a/compiler/crates/relay-compiler/src/artifact_content/content.rs +++ b/compiler/crates/relay-compiler/src/artifact_content/content.rs @@ -67,7 +67,7 @@ pub fn generate_preloadable_query_parameters( // -- Begin Disable Lint Section -- content_sections.push(ContentSection::Generic(generate_disable_lint_section( - &project_config.typegen_config.language, + &project_config, )?)); // -- End Disable Lint Section -- @@ -181,7 +181,7 @@ pub fn generate_updatable_query( // -- Begin Disable Lint Section -- content_sections.push(ContentSection::Generic(generate_disable_lint_section( - &project_config.typegen_config.language, + &project_config, )?)); // -- End Disable Lint Section -- @@ -322,7 +322,7 @@ pub fn generate_operation( // -- Begin Disable Lint Section -- content_sections.push(ContentSection::Generic(generate_disable_lint_section( - &project_config.typegen_config.language, + &project_config, )?)); // -- End Disable Lint Section -- @@ -513,7 +513,7 @@ pub fn generate_split_operation( // -- Begin Disable Lint Section -- content_sections.push(ContentSection::Generic(generate_disable_lint_section( - &project_config.typegen_config.language, + &project_config, )?)); // -- End Disable Lint Section -- @@ -665,7 +665,7 @@ fn generate_read_only_fragment( // -- Begin Disable Lint Section -- content_sections.push(ContentSection::Generic(generate_disable_lint_section( - &project_config.typegen_config.language, + &project_config, )?)); // -- End Disable Lint Section -- @@ -787,7 +787,7 @@ fn generate_assignable_fragment( // -- Begin Disable Lint Section -- content_sections.push(ContentSection::Generic(generate_disable_lint_section( - &project_config.typegen_config.language, + &project_config, )?)); // -- End Disable Lint Section -- @@ -888,12 +888,15 @@ fn write_variable_value_with_type( } } -fn generate_disable_lint_section(language: &TypegenLanguage) -> Result { +fn generate_disable_lint_section(project_config: &ProjectConfig) -> Result { let mut section = GenericSection::default(); - match language { + match project_config.typegen_config.language { TypegenLanguage::TypeScript => { writeln!(section, "/* tslint:disable */")?; writeln!(section, "/* eslint-disable */")?; + if !project_config.typegen_config.typescript_check_generated_files { + writeln!(section, "// @ts-nocheck")?; + } } TypegenLanguage::Flow | TypegenLanguage::JavaScript => { writeln!(section, "/* eslint-disable */")?; @@ -1065,7 +1068,7 @@ pub fn generate_resolvers_schema_module_content( // -- Begin Disable Lint Section -- content_sections.push(ContentSection::Generic(generate_disable_lint_section( - &project_config.typegen_config.language, + &project_config, )?)); // -- End Disable Lint Section -- diff --git a/compiler/crates/relay-compiler/tests/compile_relay_artifacts_with_custom_id.rs b/compiler/crates/relay-compiler/tests/compile_relay_artifacts_with_custom_id.rs index cc383babd29ed..cb09a6f609936 100644 --- a/compiler/crates/relay-compiler/tests/compile_relay_artifacts_with_custom_id.rs +++ b/compiler/crates/relay-compiler/tests/compile_relay_artifacts_with_custom_id.rs @@ -39,6 +39,7 @@ use relay_test_schema::get_test_schema_with_custom_id; use relay_test_schema::get_test_schema_with_custom_id_with_extensions; use relay_transforms::apply_transforms; use relay_transforms::DIRECTIVE_SPLIT_OPERATION; +use relay_typegen::TypegenConfig; pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result { let source_location = SourceLocationKey::standalone(fixture.file_name); @@ -108,6 +109,10 @@ pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result .unwrap_or(default_schema_config.node_interface_id_variable_name), ..default_schema_config }, + typegen_config: TypegenConfig { + typescript_check_generated_files: true, + ..Default::default() + }, js_module_format: JsModuleFormat::Haste, ..Default::default() }; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected index 7271e2a60868e..4fe9c17deb470 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected @@ -21,7 +21,8 @@ graphql` "schema": "./schema.graphql", "featureFlags": { "enable_fragment_argument_transform": true - } + }, + "typescriptCheckGeneratedFiles": true } //- schema.graphql diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input index a0ae4d6994536..f0a064dfcd03a 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input @@ -20,7 +20,8 @@ graphql` "schema": "./schema.graphql", "featureFlags": { "enable_fragment_argument_transform": true - } + }, + "typescriptCheckGeneratedFiles": true } //- schema.graphql diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected index 30c490afdb026..7910c65646b38 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected @@ -12,7 +12,8 @@ graphql` "eagerEsModules": true, "persistConfig": { "file": "./operations.json" - } + }, + "typescriptCheckGeneratedFiles": true } //- operations.json diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input index 676812f950e8c..9c1848fadf03c 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input @@ -11,7 +11,8 @@ graphql` "eagerEsModules": true, "persistConfig": { "file": "./operations.json" - } + }, + "typescriptCheckGeneratedFiles": true } //- operations.json diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected index 7eeea50ebb21e..0e82107064e91 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected @@ -8,7 +8,8 @@ graphql` //- relay.config.json { "language": "typescript", - "schema": "./schema.graphql" + "schema": "./schema.graphql", + "typescriptCheckGeneratedFiles": true } //- schema.graphql diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input index 58786e6edf69c..82e663c846039 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input @@ -7,7 +7,8 @@ graphql` //- relay.config.json { "language": "typescript", - "schema": "./schema.graphql" + "schema": "./schema.graphql", + "typescriptCheckGeneratedFiles": true } //- schema.graphql 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 346b0b4ba1385..d0db6951ad538 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 @@ -16,7 +16,8 @@ graphql`fragment barFragment on User { "eagerEsModules": true, "featureFlags": { "enable_relay_resolver_transform": true - } + }, + "typescriptCheckGeneratedFiles": true } //- schema.graphql diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input index a8677a89dd860..4e372c7df0b69 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input @@ -15,7 +15,8 @@ graphql`fragment barFragment on User { "eagerEsModules": true, "featureFlags": { "enable_relay_resolver_transform": true - } + }, + "typescriptCheckGeneratedFiles": true } //- schema.graphql diff --git a/compiler/crates/relay-config/src/typegen_config.rs b/compiler/crates/relay-config/src/typegen_config.rs index e1d999fd59d3e..d324e0e5df8ed 100644 --- a/compiler/crates/relay-config/src/typegen_config.rs +++ b/compiler/crates/relay-config/src/typegen_config.rs @@ -114,6 +114,10 @@ pub struct TypegenConfig { #[serde(default)] pub typescript_exclude_undefined_from_nullable_union: bool, + // todo: should this go here or in a feature flag? Above flag is discussed here: https://github.com/facebook/relay/pull/4380 + #[serde(default)] + pub typescript_check_generated_files: bool, + /// EXPERIMENTAL: If your environment is configured to handles errors out of band, either via /// a network layer which discards responses with errors, or via enabling strict /// error handling in the runtime, you can enable this flag to have Relay generate @@ -145,6 +149,7 @@ impl Default for TypegenConfig { typescript_exclude_undefined_from_nullable_union: Default::default(), experimental_emit_semantic_nullability_types: Default::default(), custom_error_type: None, + typescript_check_generated_files: Default::default(), } } } From 67ebebf80ba7526e92947d8332d102072acdc82c Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 31 Jul 2024 08:33:41 -0700 Subject: [PATCH 04/16] revert this change --- .../src/build_project/artifact_generated_types.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/crates/relay-compiler/src/build_project/artifact_generated_types.rs b/compiler/crates/relay-compiler/src/build_project/artifact_generated_types.rs index 6a395b51d6f19..3152d2eb87bcc 100644 --- a/compiler/crates/relay-compiler/src/build_project/artifact_generated_types.rs +++ b/compiler/crates/relay-compiler/src/build_project/artifact_generated_types.rs @@ -38,21 +38,21 @@ impl ArtifactGeneratedTypes { let (kind, imported_types) = match operation.kind { OperationKind::Query => { if is_client_only { - ("ClientQuery", "ClientRequest") + ("ClientQuery", "ClientRequest, ClientQuery") } else { - ("Query", "ConcreteRequest") + ("Query", "ConcreteRequest, Query") } } OperationKind::Mutation => { if is_client_only { - ("Mutation", "ClientRequest") + ("Mutation", "ClientRequest, Mutation") } else { - ("Mutation", "ConcreteRequest") + ("Mutation", "ConcreteRequest, Mutation") } } OperationKind::Subscription => ( "GraphQLSubscription", - "ConcreteRequest", + "ConcreteRequest, GraphQLSubscription", ), }; let exported_type = if has_raw_response_type_directive(operation) { From 1e699d4d707d585f47c63a722eeecd0a97a198a4 Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 31 Jul 2024 09:51:12 -0700 Subject: [PATCH 05/16] Fix test files from other branch --- .../fixtures/client_mutation_extension.expected | 4 ++-- .../fixtures/client_mutation_resolver.expected | 4 ++-- .../client_mutation_resolver_different_mutation_ok.expected | 4 ++-- ...ent_schema_extension_interface_uses_resolver_type.expected | 4 ++-- .../custom_scalar_variable_default_arg_non_strict.expected | 4 ++-- .../fixtures/error_handling_query.expected | 4 ++-- .../fixtures/fragment_arguments.expected | 4 ++-- ...e_resolvers_on_interface_of_all_strong_model_type.expected | 4 ++-- ...lvers_returns_interfaces_of_all_strong_model_type.expected | 4 ++-- .../fixtures/preloadable_query_flow.expected | 4 ++-- .../fixtures/preloadable_query_typescript.expected | 4 ++-- ...resolver_returns_interface_of_all_live_model_type.expected | 4 ++-- ...solver_returns_interface_of_all_strong_model_type.expected | 4 ++-- ..._interface_of_all_strong_model_type_including_cse.expected | 4 ++-- ...resolver_returns_interface_of_all_weak_model_type.expected | 4 ++-- ..._interface_of_live_and_non_live_strong_model_type.expected | 4 ++-- .../spread_interface_fragment_on_weak_concrete_type.expected | 4 ++-- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_extension.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_extension.expected index bf0cf6ee4cfd1..a8ff79add864b 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_extension.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_extension.expected @@ -35,7 +35,7 @@ extend type Mutation { ==================================== OUTPUT =================================== //- __generated__/barMutation.graphql.js /** - * SignedSource<<7b66b8b44ae4d0d2a0f5b850cd52853c>> + * SignedSource<<8c2ec235b8b068c2c2fffbc3aae787b8>> * @flow * @lightSyntaxTransform * @nogrep @@ -46,7 +46,7 @@ extend type Mutation { 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +import type { ClientRequest, Mutation } from 'relay-runtime'; 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.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/client_mutation_resolver.expected index 9c75d0fd8b1be..3e9340a126d26 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 @@ -32,7 +32,7 @@ type Query { ==================================== OUTPUT =================================== //- __generated__/barMutation.graphql.js /** - * SignedSource<<538b86eea851f38c2187170367298cc2>> + * SignedSource<<7f1de50339842bab9cecc72c6fbc076f>> * @flow * @lightSyntaxTransform * @nogrep @@ -43,7 +43,7 @@ type Query { 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +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. 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 cca6f34a3eb48..3b3c2e0363ed3 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 @@ -106,7 +106,7 @@ export default node; //- __generated__/barMutation.graphql.js /** - * SignedSource<<3e41ed0b1d0494106fb3c72b23df5d64>> + * SignedSource<<6f79ca8d7718498c480388c5b22a5130>> * @flow * @lightSyntaxTransform * @nogrep @@ -117,7 +117,7 @@ export default node; 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +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. 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 1882dfcb839a9..f4457c7de0df3 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 @@ -175,7 +175,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<> + * SignedSource<<678979a6fbd285c60deb8d498debb4ca>> * @flow * @lightSyntaxTransform * @nogrep @@ -186,7 +186,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +import type { ClientRequest, ClientQuery } from 'relay-runtime'; import type { DataID } from "relay-runtime"; import type { Admin____relay_model_instance$data } from "Admin____relay_model_instance.graphql"; import {admin as adminAdminResolverType} from "Admin"; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/custom_scalar_variable_default_arg_non_strict.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/custom_scalar_variable_default_arg_non_strict.expected index 17a3a1bd3532d..6c8a54a3a86f1 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/custom_scalar_variable_default_arg_non_strict.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/custom_scalar_variable_default_arg_non_strict.expected @@ -46,7 +46,7 @@ extend type Query { ==================================== OUTPUT =================================== //- __generated__/fooCustomScalarLiteralArgQuery.graphql.js /** - * SignedSource<<4f380cead53a51a6c7fb435684020240>> + * SignedSource<<27b4bcb541cbdf999e094b271c6bf062>> * @flow * @lightSyntaxTransform * @nogrep @@ -57,7 +57,7 @@ extend type Query { 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +import type { ClientRequest, ClientQuery } from 'relay-runtime'; export type fooCustomScalarLiteralArgQuery$variables = {| arg: any, arg_server: any, 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 f16d16753b498..41accfb2e2041 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 @@ -20,7 +20,7 @@ type User { name: String } ==================================== OUTPUT =================================== //- __generated__/fooQuery.graphql.js /** - * SignedSource<> + * SignedSource<<3fedea69ae18a5e38707e31bf973e7af>> * @flow * @lightSyntaxTransform * @nogrep @@ -31,7 +31,7 @@ type User { name: String } 'use strict'; /*:: -import type { ConcreteRequest } from 'relay-runtime'; +import type { ConcreteRequest, Query } from 'relay-runtime'; export type fooQuery$variables = {||}; export type fooQuery$data = {| +me: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected index 4fe9c17deb470..0d6df555ad180 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected @@ -108,7 +108,7 @@ export default node; //- __generated__/fooQuery.graphql.ts /** - * SignedSource<> + * SignedSource<<3e1d059e8950880fb479c660ec7469a5>> * @lightSyntaxTransform * @nogrep */ @@ -116,7 +116,7 @@ export default node; /* tslint:disable */ /* eslint-disable */ -import { ConcreteRequest } from 'relay-runtime'; +import { ConcreteRequest, Query } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; export type fooQuery$variables = Record; export type fooQuery$data = { 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 bbef7a7605f74..dc843e65f444c 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 @@ -180,7 +180,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -191,7 +191,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +import type { ClientRequest, ClientQuery } from 'relay-runtime'; import type { Admin____relay_model_instance$data } from "Admin____relay_model_instance.graphql"; import type { User____relay_model_instance$data } from "User____relay_model_instance.graphql"; import {description as iActorDescriptionResolverType} from "IActorResolvers"; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_returns_interfaces_of_all_strong_model_type.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_returns_interfaces_of_all_strong_model_type.expected index 301539a0c2f92..52096b0c891a6 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_returns_interfaces_of_all_strong_model_type.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/multiple_resolvers_returns_interfaces_of_all_strong_model_type.expected @@ -189,7 +189,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<<494b069860d15292419ea8b7b0af858e>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -200,7 +200,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +import type { ClientRequest, ClientQuery } from 'relay-runtime'; export type PersonComponentQuery$variables = {||}; export type PersonComponentQuery$data = {| +actor: ?{| diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_flow.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_flow.expected index d934489eb55ae..2b08a3cf1f33a 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_flow.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_flow.expected @@ -56,7 +56,7 @@ export default ((node/*: any*/)/*: PreloadableConcreteRequest*/); //- __generated__/fooQuery.graphql.js /** - * SignedSource<<8f17045eff339b57b74e875045b0f6c3>> + * SignedSource<<8cc7b8c559f66dd65618447b4688e2e9>> * @relayHash ae6874c86ce5db2df8d6b253a6a0ec13 * @flow * @lightSyntaxTransform @@ -70,7 +70,7 @@ export default ((node/*: any*/)/*: PreloadableConcreteRequest*/); // @relayRequestID ae6874c86ce5db2df8d6b253a6a0ec13 /*:: -import type { ConcreteRequest } from 'relay-runtime'; +import type { ConcreteRequest, Query } from 'relay-runtime'; export type fooQuery$variables = {||}; export type fooQuery$data = {| +userName: ?string, diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected index 7910c65646b38..77aa77ee9c212 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected @@ -53,7 +53,7 @@ export default node; //- __generated__/fooQuery.graphql.ts /** - * SignedSource<<09465a6feb3ad10a80c2e0606387a0e3>> + * SignedSource<> * @relayHash ae6874c86ce5db2df8d6b253a6a0ec13 * @lightSyntaxTransform * @nogrep @@ -64,7 +64,7 @@ export default node; // @relayRequestID ae6874c86ce5db2df8d6b253a6a0ec13 -import { ConcreteRequest } from 'relay-runtime'; +import { ConcreteRequest, Query } from 'relay-runtime'; export type fooQuery$variables = Record; export type fooQuery$data = { readonly userName: string | null | undefined; 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 15f98cd259ee3..8b835fb6b7816 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 @@ -177,7 +177,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/QueryComponentQuery.graphql.js /** - * SignedSource<> + * SignedSource<<750533be4ec90cc3f3f7cccb2bf849f4>> * @flow * @lightSyntaxTransform * @nogrep @@ -188,7 +188,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +import type { ClientRequest, ClientQuery } from 'relay-runtime'; import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. 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 a79e73bd96bf1..a6f29d6814161 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 @@ -175,7 +175,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -186,7 +186,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +import type { ClientRequest, ClientQuery } from 'relay-runtime'; import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. 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 7d84a92d58829..5f57d66d7fb92 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 @@ -180,7 +180,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/PersonComponentQuery.graphql.js /** - * SignedSource<<28018d85e2942283fbdb6c0b99ca8481>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -191,7 +191,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +import type { ClientRequest, ClientQuery } from 'relay-runtime'; import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. 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 1e864119541ae..9bd31eda8ea03 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 @@ -114,7 +114,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/QueryComponentQuery.graphql.js /** - * SignedSource<<292d01f3881655a68a78fe0b6eff9b9e>> + * SignedSource<<4c12cb9f690c4ba88d309a8e9f747867>> * @flow * @lightSyntaxTransform * @nogrep @@ -125,7 +125,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +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. 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 7b4232ffdd01b..796a41100c23e 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 @@ -176,7 +176,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/QueryComponentQuery.graphql.js /** - * SignedSource<<8525ec6ab2fa67c5c8f78ebe5e4edd11>> + * SignedSource<> * @flow * @lightSyntaxTransform * @nogrep @@ -187,7 +187,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +import type { ClientRequest, ClientQuery } from 'relay-runtime'; import type { DataID } from "relay-runtime"; import {person as queryPersonResolverType} from "QueryResolvers"; // Type assertion validating that `queryPersonResolverType` resolver is correctly implemented. 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 c4df6d7e3b088..fa1d63a33ce10 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 @@ -211,7 +211,7 @@ module.exports = ((node/*: any*/)/*: Fragment< //- __generated__/UserQueryComponentQuery.graphql.js /** - * SignedSource<<6fd845898f7b83c97be6ad0c585178c0>> + * SignedSource<<097b4c59a2a87918f0d913802fcac7cb>> * @flow * @lightSyntaxTransform * @nogrep @@ -222,7 +222,7 @@ module.exports = ((node/*: any*/)/*: Fragment< 'use strict'; /*:: -import type { ClientRequest } from 'relay-runtime'; +import type { ClientRequest, ClientQuery } from 'relay-runtime'; import type { PersonComponentFragment$fragmentType } from "PersonComponentFragment.graphql"; import {user as queryUserResolverType} from "UserTypeResolvers"; // Type assertion validating that `queryUserResolverType` resolver is correctly implemented. From a5aa1be1e4862f6de05468a0212e420f36fa3c1d Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 31 Jul 2024 09:56:03 -0700 Subject: [PATCH 06/16] relay compiler config schema --- .../relay-compiler/relay-compiler-config-schema.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/crates/relay-compiler/relay-compiler-config-schema.json b/compiler/crates/relay-compiler/relay-compiler-config-schema.json index 12d938ed4d477..ded821eec81ed 100644 --- a/compiler/crates/relay-compiler/relay-compiler-config-schema.json +++ b/compiler/crates/relay-compiler/relay-compiler-config-schema.json @@ -1672,6 +1672,10 @@ "description": "Added in 13.1.1 to customize Final/Compat mode in the single project config file Removed in 14.0.0", "default": null }, + "typescriptCheckGeneratedFiles": { + "default": false, + "type": "boolean" + }, "typescriptExcludeUndefinedFromNullableUnion": { "description": "Keep the previous compiler behavior by outputting an union of the raw type and null, and not the **correct** behavior of an union with the raw type, null and undefined.", "default": false, @@ -4726,6 +4730,10 @@ "null" ] }, + "typescriptCheckGeneratedFiles": { + "default": false, + "type": "boolean" + }, "typescriptExcludeUndefinedFromNullableUnion": { "description": "Keep the previous compiler behavior by outputting an union of the raw type and null, and not the **correct** behavior of an union with the raw type, null and undefined.", "default": false, From 4978898210658df5aae0e1586b6c2fc27902d5f3 Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 31 Jul 2024 10:08:03 -0700 Subject: [PATCH 07/16] Move compiler config to feature flag, update tests --- compiler/crates/common/src/feature_flags.rs | 4 ++++ .../relay-compiler-config-schema.json | 23 +++++++++++-------- .../src/artifact_content/content.rs | 2 +- .../compile_relay_artifacts_with_custom_id.rs | 5 ---- .../fixtures/fragment_arguments.expected | 6 ++--- .../fixtures/fragment_arguments.input | 6 ++--- .../preloadable_query_typescript.expected | 4 +++- .../preloadable_query_typescript.input | 4 +++- .../fixtures/simple_fragment.expected | 4 +++- .../fixtures/simple_fragment.input | 4 +++- .../typescript_resolver_type_import.expected | 6 ++--- .../typescript_resolver_type_import.input | 6 ++--- .../crates/relay-config/src/typegen_config.rs | 5 ---- 13 files changed, 43 insertions(+), 36 deletions(-) diff --git a/compiler/crates/common/src/feature_flags.rs b/compiler/crates/common/src/feature_flags.rs index 65c6808e75ef5..7a30cd460523e 100644 --- a/compiler/crates/common/src/feature_flags.rs +++ b/compiler/crates/common/src/feature_flags.rs @@ -124,6 +124,10 @@ pub struct FeatureFlags { /// Disable validation of the `edgeTypeName` argument on `@prependNode` and `@appendNode`. #[serde(default)] pub disable_edge_type_name_validation_on_declerative_connection_directives: FeatureFlag, + + // Removes the @ts-nocheck pragma from generated Typescript Files + #[serde(default)] + pub typescript_check_generated_files: bool, } #[derive(Debug, Deserialize, Clone, Serialize, Default, JsonSchema)] diff --git a/compiler/crates/relay-compiler/relay-compiler-config-schema.json b/compiler/crates/relay-compiler/relay-compiler-config-schema.json index ded821eec81ed..129da755a190a 100644 --- a/compiler/crates/relay-compiler/relay-compiler-config-schema.json +++ b/compiler/crates/relay-compiler/relay-compiler-config-schema.json @@ -1277,6 +1277,10 @@ } } ] + }, + "typescript_check_generated_files": { + "default": false, + "type": "boolean" } }, "additionalProperties": false @@ -1672,10 +1676,6 @@ "description": "Added in 13.1.1 to customize Final/Compat mode in the single project config file Removed in 14.0.0", "default": null }, - "typescriptCheckGeneratedFiles": { - "default": false, - "type": "boolean" - }, "typescriptExcludeUndefinedFromNullableUnion": { "description": "Keep the previous compiler behavior by outputting an union of the raw type and null, and not the **correct** behavior of an union with the raw type, null and undefined.", "default": false, @@ -1774,7 +1774,8 @@ }, "text_artifacts": { "kind": "disabled" - } + }, + "typescript_check_generated_files": false }, "type": "object", "properties": { @@ -2939,6 +2940,10 @@ } } ] + }, + "typescript_check_generated_files": { + "default": false, + "type": "boolean" } }, "additionalProperties": false @@ -4307,6 +4312,10 @@ } } ] + }, + "typescript_check_generated_files": { + "default": false, + "type": "boolean" } }, "additionalProperties": false @@ -4730,10 +4739,6 @@ "null" ] }, - "typescriptCheckGeneratedFiles": { - "default": false, - "type": "boolean" - }, "typescriptExcludeUndefinedFromNullableUnion": { "description": "Keep the previous compiler behavior by outputting an union of the raw type and null, and not the **correct** behavior of an union with the raw type, null and undefined.", "default": false, diff --git a/compiler/crates/relay-compiler/src/artifact_content/content.rs b/compiler/crates/relay-compiler/src/artifact_content/content.rs index 9dec3d620d64e..b86fcb544abb7 100644 --- a/compiler/crates/relay-compiler/src/artifact_content/content.rs +++ b/compiler/crates/relay-compiler/src/artifact_content/content.rs @@ -894,7 +894,7 @@ fn generate_disable_lint_section(project_config: &ProjectConfig) -> Result { writeln!(section, "/* tslint:disable */")?; writeln!(section, "/* eslint-disable */")?; - if !project_config.typegen_config.typescript_check_generated_files { + if !project_config.feature_flags.typescript_check_generated_files { writeln!(section, "// @ts-nocheck")?; } } diff --git a/compiler/crates/relay-compiler/tests/compile_relay_artifacts_with_custom_id.rs b/compiler/crates/relay-compiler/tests/compile_relay_artifacts_with_custom_id.rs index cb09a6f609936..cc383babd29ed 100644 --- a/compiler/crates/relay-compiler/tests/compile_relay_artifacts_with_custom_id.rs +++ b/compiler/crates/relay-compiler/tests/compile_relay_artifacts_with_custom_id.rs @@ -39,7 +39,6 @@ use relay_test_schema::get_test_schema_with_custom_id; use relay_test_schema::get_test_schema_with_custom_id_with_extensions; use relay_transforms::apply_transforms; use relay_transforms::DIRECTIVE_SPLIT_OPERATION; -use relay_typegen::TypegenConfig; pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result { let source_location = SourceLocationKey::standalone(fixture.file_name); @@ -109,10 +108,6 @@ pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result .unwrap_or(default_schema_config.node_interface_id_variable_name), ..default_schema_config }, - typegen_config: TypegenConfig { - typescript_check_generated_files: true, - ..Default::default() - }, js_module_format: JsModuleFormat::Haste, ..Default::default() }; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected index 0d6df555ad180..51c3b748d777c 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected @@ -20,9 +20,9 @@ graphql` "language": "typescript", "schema": "./schema.graphql", "featureFlags": { - "enable_fragment_argument_transform": true - }, - "typescriptCheckGeneratedFiles": true + "enable_fragment_argument_transform": true, + "typescript_check_generated_files": true + } } //- schema.graphql diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input index f0a064dfcd03a..c9c04d41b7eda 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input @@ -19,9 +19,9 @@ graphql` "language": "typescript", "schema": "./schema.graphql", "featureFlags": { - "enable_fragment_argument_transform": true - }, - "typescriptCheckGeneratedFiles": true + "enable_fragment_argument_transform": true, + "typescript_check_generated_files": true + } } //- schema.graphql diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected index 77aa77ee9c212..d37554b7a9777 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected @@ -13,7 +13,9 @@ graphql` "persistConfig": { "file": "./operations.json" }, - "typescriptCheckGeneratedFiles": true + "featureFlags": { + "typescript_check_generated_files": true + } } //- operations.json diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input index 9c1848fadf03c..c4120bc086cee 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input @@ -12,7 +12,9 @@ graphql` "persistConfig": { "file": "./operations.json" }, - "typescriptCheckGeneratedFiles": true + "featureFlags": { + "typescript_check_generated_files": true + } } //- operations.json diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected index 0e82107064e91..337e7278f1e49 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected @@ -9,7 +9,9 @@ graphql` { "language": "typescript", "schema": "./schema.graphql", - "typescriptCheckGeneratedFiles": true + "featureFlags": { + "typescript_check_generated_files": true + } } //- schema.graphql diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input index 82e663c846039..e3de685a4275d 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input @@ -8,7 +8,9 @@ graphql` { "language": "typescript", "schema": "./schema.graphql", - "typescriptCheckGeneratedFiles": true + "featureFlags": { + "typescript_check_generated_files": true + } } //- schema.graphql 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 d0db6951ad538..365ed7914a934 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 @@ -15,9 +15,9 @@ graphql`fragment barFragment on User { "schema": "./schema.graphql", "eagerEsModules": true, "featureFlags": { - "enable_relay_resolver_transform": true - }, - "typescriptCheckGeneratedFiles": true + "enable_relay_resolver_transform": true, + "typescript_check_generated_files": true + } } //- schema.graphql diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input index 4e372c7df0b69..b7ed2f50399ad 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input @@ -14,9 +14,9 @@ graphql`fragment barFragment on User { "schema": "./schema.graphql", "eagerEsModules": true, "featureFlags": { - "enable_relay_resolver_transform": true - }, - "typescriptCheckGeneratedFiles": true + "enable_relay_resolver_transform": true, + "typescript_check_generated_files": true + } } //- schema.graphql diff --git a/compiler/crates/relay-config/src/typegen_config.rs b/compiler/crates/relay-config/src/typegen_config.rs index d324e0e5df8ed..e1d999fd59d3e 100644 --- a/compiler/crates/relay-config/src/typegen_config.rs +++ b/compiler/crates/relay-config/src/typegen_config.rs @@ -114,10 +114,6 @@ pub struct TypegenConfig { #[serde(default)] pub typescript_exclude_undefined_from_nullable_union: bool, - // todo: should this go here or in a feature flag? Above flag is discussed here: https://github.com/facebook/relay/pull/4380 - #[serde(default)] - pub typescript_check_generated_files: bool, - /// EXPERIMENTAL: If your environment is configured to handles errors out of band, either via /// a network layer which discards responses with errors, or via enabling strict /// error handling in the runtime, you can enable this flag to have Relay generate @@ -149,7 +145,6 @@ impl Default for TypegenConfig { typescript_exclude_undefined_from_nullable_union: Default::default(), experimental_emit_semantic_nullability_types: Default::default(), custom_error_type: None, - typescript_check_generated_files: Default::default(), } } } From 90ee824917d4c2cdfe0863802eb1a131e568fb33 Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 31 Jul 2024 10:11:44 -0700 Subject: [PATCH 08/16] Removing flag from tests --- .../fixtures/fragment_arguments.expected | 9 +++++---- .../fixtures/fragment_arguments.input | 3 +-- .../fixtures/preloadable_query_typescript.expected | 9 ++++----- .../fixtures/preloadable_query_typescript.input | 3 --- .../fixtures/simple_fragment.expected | 8 +++----- .../fixtures/simple_fragment.input | 5 +---- .../fixtures/typescript_resolver_type_import.expected | 6 +++--- .../fixtures/typescript_resolver_type_import.input | 3 +-- 8 files changed, 18 insertions(+), 28 deletions(-) diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected index 51c3b748d777c..f7281490fa873 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.expected @@ -20,8 +20,7 @@ graphql` "language": "typescript", "schema": "./schema.graphql", "featureFlags": { - "enable_fragment_argument_transform": true, - "typescript_check_generated_files": true + "enable_fragment_argument_transform": true } } @@ -40,13 +39,14 @@ type Post { ==================================== OUTPUT =================================== //- __generated__/foo.graphql.ts /** - * SignedSource<<7ff63745b7dbb2c82d5d1c126c4eba41>> + * SignedSource<<0e503f5c200310a5580a2b4853a499ce>> * @lightSyntaxTransform * @nogrep */ /* tslint:disable */ /* eslint-disable */ +// @ts-nocheck import { Fragment, ReaderFragment } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; @@ -108,13 +108,14 @@ export default node; //- __generated__/fooQuery.graphql.ts /** - * SignedSource<<3e1d059e8950880fb479c660ec7469a5>> + * SignedSource<<20043d1d00f946a33727d27907f7f3f2>> * @lightSyntaxTransform * @nogrep */ /* tslint:disable */ /* eslint-disable */ +// @ts-nocheck import { ConcreteRequest, Query } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input index c9c04d41b7eda..a0ae4d6994536 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/fragment_arguments.input @@ -19,8 +19,7 @@ graphql` "language": "typescript", "schema": "./schema.graphql", "featureFlags": { - "enable_fragment_argument_transform": true, - "typescript_check_generated_files": true + "enable_fragment_argument_transform": true } } diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected index d37554b7a9777..e5fe00c999739 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.expected @@ -12,9 +12,6 @@ graphql` "eagerEsModules": true, "persistConfig": { "file": "./operations.json" - }, - "featureFlags": { - "typescript_check_generated_files": true } } @@ -26,7 +23,7 @@ type Query { userName: String } ==================================== OUTPUT =================================== //- __generated__/fooQuery$parameters.ts /** - * SignedSource<> + * SignedSource<<7de8baf3626a3ece606b72c2ece21848>> * @relayHash ae6874c86ce5db2df8d6b253a6a0ec13 * @lightSyntaxTransform * @nogrep @@ -34,6 +31,7 @@ type Query { userName: String } /* tslint:disable */ /* eslint-disable */ +// @ts-nocheck // @relayRequestID ae6874c86ce5db2df8d6b253a6a0ec13 @@ -55,7 +53,7 @@ export default node; //- __generated__/fooQuery.graphql.ts /** - * SignedSource<> + * SignedSource<<461989c03655ebfecf253b741f65ef91>> * @relayHash ae6874c86ce5db2df8d6b253a6a0ec13 * @lightSyntaxTransform * @nogrep @@ -63,6 +61,7 @@ export default node; /* tslint:disable */ /* eslint-disable */ +// @ts-nocheck // @relayRequestID ae6874c86ce5db2df8d6b253a6a0ec13 diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input index c4120bc086cee..676812f950e8c 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/preloadable_query_typescript.input @@ -11,9 +11,6 @@ graphql` "eagerEsModules": true, "persistConfig": { "file": "./operations.json" - }, - "featureFlags": { - "typescript_check_generated_files": true } } diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected index 337e7278f1e49..67dd12c461485 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.expected @@ -8,10 +8,7 @@ graphql` //- relay.config.json { "language": "typescript", - "schema": "./schema.graphql", - "featureFlags": { - "typescript_check_generated_files": true - } + "schema": "./schema.graphql" } //- schema.graphql @@ -20,13 +17,14 @@ type User { name: String } ==================================== OUTPUT =================================== //- __generated__/foo.graphql.ts /** - * SignedSource<> + * SignedSource<> * @lightSyntaxTransform * @nogrep */ /* tslint:disable */ /* eslint-disable */ +// @ts-nocheck import { Fragment, ReaderFragment } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input index e3de685a4275d..58786e6edf69c 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/simple_fragment.input @@ -7,10 +7,7 @@ graphql` //- relay.config.json { "language": "typescript", - "schema": "./schema.graphql", - "featureFlags": { - "typescript_check_generated_files": true - } + "schema": "./schema.graphql" } //- schema.graphql 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 365ed7914a934..e8c1d60403663 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 @@ -15,8 +15,7 @@ graphql`fragment barFragment on User { "schema": "./schema.graphql", "eagerEsModules": true, "featureFlags": { - "enable_relay_resolver_transform": true, - "typescript_check_generated_files": true + "enable_relay_resolver_transform": true } } @@ -26,13 +25,14 @@ type User { name: String } ==================================== OUTPUT =================================== //- __generated__/barFragment.graphql.ts /** - * SignedSource<> + * SignedSource<<6c58dff465555ee63fe212edde3a3e01>> * @lightSyntaxTransform * @nogrep */ /* tslint:disable */ /* eslint-disable */ +// @ts-nocheck import { Fragment, ReaderFragment } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input index b7ed2f50399ad..a8677a89dd860 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_resolver_type_import.input @@ -14,8 +14,7 @@ graphql`fragment barFragment on User { "schema": "./schema.graphql", "eagerEsModules": true, "featureFlags": { - "enable_relay_resolver_transform": true, - "typescript_check_generated_files": true + "enable_relay_resolver_transform": true } } From 653b1dd1729c39b0b53c01faa16975447dbcb835 Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 31 Jul 2024 10:44:43 -0700 Subject: [PATCH 09/16] Add fixture test for nocheck flag --- .../typescript_check_generated_files.expected | 67 +++++++++++++++++++ .../typescript_check_generated_files.input | 23 +++++++ .../tests/relay_compiler_integration_test.rs | 9 ++- 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.expected create mode 100644 compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.input diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.expected new file mode 100644 index 0000000000000..6778b9a911091 --- /dev/null +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.expected @@ -0,0 +1,67 @@ +==================================== INPUT ==================================== +//- foo.ts +/** + * @RelayResolver User.foo: RelayResolverValue + */ + +//- bar.ts +graphql`fragment barFragment on User { + foo +}` + +//- relay.config.json +{ + "language": "typescript", + "schema": "./schema.graphql", + "eagerEsModules": true, + "featureFlags": { + "typescript_check_generated_files": true + } +} + +//- schema.graphql +type Query { user: User } +type User { foo: String } +==================================== OUTPUT =================================== +//- __generated__/barFragment.graphql.ts +/** + * SignedSource<> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ + +import { Fragment, ReaderFragment } from 'relay-runtime'; +import { FragmentRefs } from "relay-runtime"; +export type barFragment$data = { + readonly foo: string | null | undefined; + readonly " $fragmentType": "barFragment"; +}; +export type barFragment$key = { + readonly " $data"?: barFragment$data; + readonly " $fragmentSpreads": FragmentRefs<"barFragment">; +}; + +const node: ReaderFragment = { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": null, + "name": "barFragment", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "foo", + "storageKey": null + } + ], + "type": "User", + "abstractKey": null +}; + +(node as any).hash = "f60f2dcc6b71a6c9ec170e68dc2c994d"; + +export default node; diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.input new file mode 100644 index 0000000000000..0ae87ae16e838 --- /dev/null +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.input @@ -0,0 +1,23 @@ +//- foo.ts +/** + * @RelayResolver User.foo: RelayResolverValue + */ + +//- bar.ts +graphql`fragment barFragment on User { + foo +}` + +//- relay.config.json +{ + "language": "typescript", + "schema": "./schema.graphql", + "eagerEsModules": true, + "featureFlags": { + "typescript_check_generated_files": true + } +} + +//- schema.graphql +type Query { user: User } +type User { foo: String } diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs b/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs index 6695a5773fd23..49ea6ac03098c 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<58762aeeff855edc7a25f98a2b63153f>> + * @generated SignedSource<> */ mod relay_compiler_integration; @@ -390,6 +390,13 @@ async fn spread_multiple_interface_fragments_on_concrete_type() { test_fixture(transform_fixture, file!(), "spread_multiple_interface_fragments_on_concrete_type.input", "relay_compiler_integration/fixtures/spread_multiple_interface_fragments_on_concrete_type.expected", input, expected).await; } +#[tokio::test] +async fn typescript_check_generated_files() { + let input = include_str!("relay_compiler_integration/fixtures/typescript_check_generated_files.input"); + let expected = include_str!("relay_compiler_integration/fixtures/typescript_check_generated_files.expected"); + test_fixture(transform_fixture, file!(), "typescript_check_generated_files.input", "relay_compiler_integration/fixtures/typescript_check_generated_files.expected", input, expected).await; +} + #[tokio::test] async fn typescript_resolver_type_import() { let input = include_str!("relay_compiler_integration/fixtures/typescript_resolver_type_import.input"); From 391f3c9a3cc7450471fa2c5051698598909bcd55 Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 31 Jul 2024 10:46:08 -0700 Subject: [PATCH 10/16] lint --- .../relay-compiler/src/artifact_content/content.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/crates/relay-compiler/src/artifact_content/content.rs b/compiler/crates/relay-compiler/src/artifact_content/content.rs index b86fcb544abb7..0fb04ff7bb86d 100644 --- a/compiler/crates/relay-compiler/src/artifact_content/content.rs +++ b/compiler/crates/relay-compiler/src/artifact_content/content.rs @@ -888,13 +888,18 @@ fn write_variable_value_with_type( } } -fn generate_disable_lint_section(project_config: &ProjectConfig) -> Result { +fn generate_disable_lint_section( + project_config: &ProjectConfig, +) -> Result { let mut section = GenericSection::default(); match project_config.typegen_config.language { TypegenLanguage::TypeScript => { writeln!(section, "/* tslint:disable */")?; writeln!(section, "/* eslint-disable */")?; - if !project_config.feature_flags.typescript_check_generated_files { + if !project_config + .feature_flags + .typescript_check_generated_files + { writeln!(section, "// @ts-nocheck")?; } } From 3adbc3b1bd05f489a63a716d92d7225850cb02ca Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 31 Jul 2024 10:47:16 -0700 Subject: [PATCH 11/16] fix: comment --- compiler/crates/common/src/feature_flags.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/crates/common/src/feature_flags.rs b/compiler/crates/common/src/feature_flags.rs index 7a30cd460523e..271a4d3dbd7d5 100644 --- a/compiler/crates/common/src/feature_flags.rs +++ b/compiler/crates/common/src/feature_flags.rs @@ -125,7 +125,7 @@ pub struct FeatureFlags { #[serde(default)] pub disable_edge_type_name_validation_on_declerative_connection_directives: FeatureFlag, - // Removes the @ts-nocheck pragma from generated Typescript Files + // Removes the @ts-nocheck from generated Typescript Files #[serde(default)] pub typescript_check_generated_files: bool, } From 9f50388f284994a3b700f6c2d8cc3584bfea2d08 Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 31 Jul 2024 13:43:31 -0700 Subject: [PATCH 12/16] invert flag and default to true --- compiler/crates/common/src/feature_flags.rs | 46 +++++++++++++++++-- .../relay-compiler-config-schema.json | 17 ++++--- .../src/artifact_content/content.rs | 4 +- ...disable_checking_generated_files.expected} | 2 +- ...pt_disable_checking_generated_files.input} | 2 +- .../tests/relay_compiler_integration_test.rs | 10 ++-- 6 files changed, 61 insertions(+), 20 deletions(-) rename compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/{typescript_check_generated_files.expected => typescript_disable_checking_generated_files.expected} (96%) rename compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/{typescript_check_generated_files.input => typescript_disable_checking_generated_files.input} (85%) diff --git a/compiler/crates/common/src/feature_flags.rs b/compiler/crates/common/src/feature_flags.rs index 271a4d3dbd7d5..a52b29c8d6980 100644 --- a/compiler/crates/common/src/feature_flags.rs +++ b/compiler/crates/common/src/feature_flags.rs @@ -18,7 +18,7 @@ use serde::Serialize; use crate::Rollout; -#[derive(Default, Debug, Serialize, Deserialize, Clone, JsonSchema)] +#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)] #[serde(deny_unknown_fields)] pub struct FeatureFlags { #[serde(default)] @@ -125,11 +125,43 @@ pub struct FeatureFlags { #[serde(default)] pub disable_edge_type_name_validation_on_declerative_connection_directives: FeatureFlag, - // Removes the @ts-nocheck from generated Typescript Files - #[serde(default)] - pub typescript_check_generated_files: bool, + /// Adds @ts-nocheck to generated Typescript Files + #[serde(default = "default_true")] + pub typescript_disable_checking_generated_files: bool, +} + +impl Default for FeatureFlags { + fn default() -> Self { + Self { + enable_relay_resolver_transform: false, + enable_catch_directive_transform: Default::default(), + relay_resolver_enable_interface_output_type: Default::default(), + no_inline: Default::default(), + enable_3d_branch_arg_generation: false, + actor_change_support: Default::default(), + text_artifacts: Default::default(), + skip_printing_nulls: Default::default(), + enable_fragment_aliases: Default::default(), + enforce_fragment_alias_where_ambiguous: Default::default(), + compact_query_text: Default::default(), + enable_resolver_normalization_ast: false, + enable_relay_resolver_mutations: false, + enable_strict_custom_scalars: false, + allow_resolvers_in_mutation_response: Default::default(), + allow_required_in_mutation_response: Default::default(), + disable_resolver_reader_ast: false, + enable_fragment_argument_transform: false, + allow_resolver_non_nullable_return_type: Default::default(), + disable_schema_validation: false, + disallow_required_on_non_null_fields: false, + prefer_fetchable_in_refetch_queries: false, + disable_edge_type_name_validation_on_declerative_connection_directives: Default::default(), + typescript_disable_checking_generated_files: default_true(), + } + } } + #[derive(Debug, Deserialize, Clone, Serialize, Default, JsonSchema)] #[serde(tag = "kind", rename_all = "lowercase")] pub enum FeatureFlag { @@ -176,3 +208,9 @@ impl Display for FeatureFlag { } } } + +// Returns true by default for the `typescript_disable_checking_generated_files` feature flag +fn default_true() -> bool { + true +} + diff --git a/compiler/crates/relay-compiler/relay-compiler-config-schema.json b/compiler/crates/relay-compiler/relay-compiler-config-schema.json index 129da755a190a..85bd875299a6f 100644 --- a/compiler/crates/relay-compiler/relay-compiler-config-schema.json +++ b/compiler/crates/relay-compiler/relay-compiler-config-schema.json @@ -1278,8 +1278,9 @@ } ] }, - "typescript_check_generated_files": { - "default": false, + "typescript_disable_checking_generated_files": { + "description": "Adds @ts-nocheck to generated Typescript Files", + "default": true, "type": "boolean" } }, @@ -1775,7 +1776,7 @@ "text_artifacts": { "kind": "disabled" }, - "typescript_check_generated_files": false + "typescript_disable_checking_generated_files": true }, "type": "object", "properties": { @@ -2941,8 +2942,9 @@ } ] }, - "typescript_check_generated_files": { - "default": false, + "typescript_disable_checking_generated_files": { + "description": "Adds @ts-nocheck to generated Typescript Files", + "default": true, "type": "boolean" } }, @@ -4313,8 +4315,9 @@ } ] }, - "typescript_check_generated_files": { - "default": false, + "typescript_disable_checking_generated_files": { + "description": "Adds @ts-nocheck to generated Typescript Files", + "default": true, "type": "boolean" } }, diff --git a/compiler/crates/relay-compiler/src/artifact_content/content.rs b/compiler/crates/relay-compiler/src/artifact_content/content.rs index 0fb04ff7bb86d..fd68df9163781 100644 --- a/compiler/crates/relay-compiler/src/artifact_content/content.rs +++ b/compiler/crates/relay-compiler/src/artifact_content/content.rs @@ -896,9 +896,9 @@ fn generate_disable_lint_section( TypegenLanguage::TypeScript => { writeln!(section, "/* tslint:disable */")?; writeln!(section, "/* eslint-disable */")?; - if !project_config + if project_config .feature_flags - .typescript_check_generated_files + .typescript_disable_checking_generated_files { writeln!(section, "// @ts-nocheck")?; } diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.expected similarity index 96% rename from compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.expected rename to compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.expected index 6778b9a911091..4ac95206607ad 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.expected @@ -15,7 +15,7 @@ graphql`fragment barFragment on User { "schema": "./schema.graphql", "eagerEsModules": true, "featureFlags": { - "typescript_check_generated_files": true + "typescript_disable_checking_generated_files": false } } diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.input b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.input similarity index 85% rename from compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.input rename to compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.input index 0ae87ae16e838..3832565b3478c 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_check_generated_files.input +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.input @@ -14,7 +14,7 @@ graphql`fragment barFragment on User { "schema": "./schema.graphql", "eagerEsModules": true, "featureFlags": { - "typescript_check_generated_files": true + "typescript_disable_checking_generated_files": false } } diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs b/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs index 49ea6ac03098c..d78b2a24198f5 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> */ mod relay_compiler_integration; @@ -391,10 +391,10 @@ async fn spread_multiple_interface_fragments_on_concrete_type() { } #[tokio::test] -async fn typescript_check_generated_files() { - let input = include_str!("relay_compiler_integration/fixtures/typescript_check_generated_files.input"); - let expected = include_str!("relay_compiler_integration/fixtures/typescript_check_generated_files.expected"); - test_fixture(transform_fixture, file!(), "typescript_check_generated_files.input", "relay_compiler_integration/fixtures/typescript_check_generated_files.expected", input, expected).await; +async fn typescript_disable_checking_generated_files() { + let input = include_str!("relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.input"); + let expected = include_str!("relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.expected"); + test_fixture(transform_fixture, file!(), "typescript_disable_checking_generated_files.input", "relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.expected", input, expected).await; } #[tokio::test] From 1ad498a1a5337bfa8ab18f56ccf2d104f83042e9 Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 18 Sep 2024 10:54:54 -0700 Subject: [PATCH 13/16] fix missing FFs --- compiler/crates/common/src/feature_flags.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/crates/common/src/feature_flags.rs b/compiler/crates/common/src/feature_flags.rs index 845799398982b..3a57313d18bcd 100644 --- a/compiler/crates/common/src/feature_flags.rs +++ b/compiler/crates/common/src/feature_flags.rs @@ -147,14 +147,12 @@ impl Default for FeatureFlags { fn default() -> Self { Self { enable_relay_resolver_transform: false, - enable_catch_directive_transform: Default::default(), relay_resolver_enable_interface_output_type: Default::default(), no_inline: Default::default(), enable_3d_branch_arg_generation: false, actor_change_support: Default::default(), text_artifacts: Default::default(), skip_printing_nulls: Default::default(), - enable_fragment_aliases: Default::default(), enforce_fragment_alias_where_ambiguous: Default::default(), compact_query_text: Default::default(), enable_resolver_normalization_ast: false, @@ -166,10 +164,12 @@ impl Default for FeatureFlags { enable_fragment_argument_transform: false, allow_resolver_non_nullable_return_type: Default::default(), disable_schema_validation: false, - disallow_required_on_non_null_fields: false, prefer_fetchable_in_refetch_queries: false, disable_edge_type_name_validation_on_declerative_connection_directives: Default::default(), typescript_disable_checking_generated_files: default_true(), + enable_exec_time_resolvers_directive: false, + disable_full_argument_type_validation: Default::default(), + enable_custom_artifacts_path: Default::default(), } } } From fedde1b5f9d3219fa5a8df299f7b0e2c8f7402a3 Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 18 Sep 2024 11:08:50 -0700 Subject: [PATCH 14/16] update typescript_disable_checking_generated_files test --- .../typescript_disable_checking_generated_files.expected | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.expected b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.expected index 4ac95206607ad..2b49232928c63 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.expected +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration/fixtures/typescript_disable_checking_generated_files.expected @@ -25,7 +25,7 @@ type User { foo: String } ==================================== OUTPUT =================================== //- __generated__/barFragment.graphql.ts /** - * SignedSource<> + * SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -33,7 +33,7 @@ type User { foo: String } /* tslint:disable */ /* eslint-disable */ -import { Fragment, ReaderFragment } from 'relay-runtime'; +import { ReaderFragment } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; export type barFragment$data = { readonly foo: string | null | undefined; From ea768c77a4e7b75d01e79815d3e25c5239f4560f Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 18 Sep 2024 11:26:29 -0700 Subject: [PATCH 15/16] lint --- compiler/crates/common/src/feature_flags.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/crates/common/src/feature_flags.rs b/compiler/crates/common/src/feature_flags.rs index 3a57313d18bcd..a65d122f5641d 100644 --- a/compiler/crates/common/src/feature_flags.rs +++ b/compiler/crates/common/src/feature_flags.rs @@ -122,7 +122,7 @@ pub struct FeatureFlags { /// Adds @ts-nocheck to generated Typescript Files #[serde(default = "default_true")] pub typescript_disable_checking_generated_files: bool, - + /// Disable full GraphQL argument type validation. Historically, we only applied argument type /// validation to the query that was actually going to be persisted and sent /// to the server. This meant that we didn't typecheck arguments passed to @@ -165,7 +165,8 @@ impl Default for FeatureFlags { allow_resolver_non_nullable_return_type: Default::default(), disable_schema_validation: false, prefer_fetchable_in_refetch_queries: false, - disable_edge_type_name_validation_on_declerative_connection_directives: Default::default(), + disable_edge_type_name_validation_on_declerative_connection_directives: + Default::default(), typescript_disable_checking_generated_files: default_true(), enable_exec_time_resolvers_directive: false, disable_full_argument_type_validation: Default::default(), @@ -174,7 +175,6 @@ impl Default for FeatureFlags { } } - #[derive(Debug, Deserialize, Clone, Serialize, Default, JsonSchema)] #[serde(tag = "kind", rename_all = "lowercase")] pub enum FeatureFlag { @@ -226,4 +226,3 @@ impl Display for FeatureFlag { fn default_true() -> bool { true } - From 8a8aa920623ba39f13a8c6c4d0152f909206bbcc Mon Sep 17 00:00:00 2001 From: Drew Atkinson Date: Wed, 18 Sep 2024 11:41:47 -0700 Subject: [PATCH 16/16] fix test generation --- .../relay-compiler/tests/relay_compiler_integration_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs b/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs index 5770adb5125c8..9c9ae37096e2a 100644 --- a/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs +++ b/compiler/crates/relay-compiler/tests/relay_compiler_integration_test.rs @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<4a187a561407aa9fb9576d43e789725b>> + * @generated SignedSource<<95c0bd13a358c7cec62c779db71d97ba>> */ mod relay_compiler_integration;