/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @generated SignedSource<<fe6689a7953b227a33d0f86a2ab54818>>
 */

mod validate_deprecated_fields;

use validate_deprecated_fields::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn deprecated_directive_arg() {
    let input = include_str!("validate_deprecated_fields/fixtures/deprecated_directive_arg.graphql");
    let expected = include_str!("validate_deprecated_fields/fixtures/deprecated_directive_arg.expected");
    test_fixture(transform_fixture, "deprecated_directive_arg.graphql", "validate_deprecated_fields/fixtures/deprecated_directive_arg.expected", input, expected);
}

#[test]
fn deprecated_directive_arg_with_reason() {
    let input = include_str!("validate_deprecated_fields/fixtures/deprecated_directive_arg_with_reason.graphql");
    let expected = include_str!("validate_deprecated_fields/fixtures/deprecated_directive_arg_with_reason.expected");
    test_fixture(transform_fixture, "deprecated_directive_arg_with_reason.graphql", "validate_deprecated_fields/fixtures/deprecated_directive_arg_with_reason.expected", input, expected);
}

#[test]
fn deprecated_field_arg() {
    let input = include_str!("validate_deprecated_fields/fixtures/deprecated_field_arg.graphql");
    let expected = include_str!("validate_deprecated_fields/fixtures/deprecated_field_arg.expected");
    test_fixture(transform_fixture, "deprecated_field_arg.graphql", "validate_deprecated_fields/fixtures/deprecated_field_arg.expected", input, expected);
}

#[test]
fn deprecated_field_arg_with_reason() {
    let input = include_str!("validate_deprecated_fields/fixtures/deprecated_field_arg_with_reason.graphql");
    let expected = include_str!("validate_deprecated_fields/fixtures/deprecated_field_arg_with_reason.expected");
    test_fixture(transform_fixture, "deprecated_field_arg_with_reason.graphql", "validate_deprecated_fields/fixtures/deprecated_field_arg_with_reason.expected", input, expected);
}

#[test]
fn deprecated_field_with_arguments() {
    let input = include_str!("validate_deprecated_fields/fixtures/deprecated_field_with_arguments.graphql");
    let expected = include_str!("validate_deprecated_fields/fixtures/deprecated_field_with_arguments.expected");
    test_fixture(transform_fixture, "deprecated_field_with_arguments.graphql", "validate_deprecated_fields/fixtures/deprecated_field_with_arguments.expected", input, expected);
}

#[test]
fn deprecated_field_with_reason() {
    let input = include_str!("validate_deprecated_fields/fixtures/deprecated_field_with_reason.graphql");
    let expected = include_str!("validate_deprecated_fields/fixtures/deprecated_field_with_reason.expected");
    test_fixture(transform_fixture, "deprecated_field_with_reason.graphql", "validate_deprecated_fields/fixtures/deprecated_field_with_reason.expected", input, expected);
}

#[test]
fn deprecated_linked_field() {
    let input = include_str!("validate_deprecated_fields/fixtures/deprecated_linked_field.graphql");
    let expected = include_str!("validate_deprecated_fields/fixtures/deprecated_linked_field.expected");
    test_fixture(transform_fixture, "deprecated_linked_field.graphql", "validate_deprecated_fields/fixtures/deprecated_linked_field.expected", input, expected);
}

#[test]
fn deprecated_scalar_field() {
    let input = include_str!("validate_deprecated_fields/fixtures/deprecated_scalar_field.graphql");
    let expected = include_str!("validate_deprecated_fields/fixtures/deprecated_scalar_field.expected");
    test_fixture(transform_fixture, "deprecated_scalar_field.graphql", "validate_deprecated_fields/fixtures/deprecated_scalar_field.expected", input, expected);
}

#[test]
fn deprecated_scalar_field_within_linked_field() {
    let input = include_str!("validate_deprecated_fields/fixtures/deprecated_scalar_field_within_linked_field.graphql");
    let expected = include_str!("validate_deprecated_fields/fixtures/deprecated_scalar_field_within_linked_field.expected");
    test_fixture(transform_fixture, "deprecated_scalar_field_within_linked_field.graphql", "validate_deprecated_fields/fixtures/deprecated_scalar_field_within_linked_field.expected", input, expected);
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @generated SignedSource<<6103440a7211fcb7a084c2b65bdc9621>>
 */

mod validate_global_variables;

use validate_global_variables::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn fragment_include_with_provided_argument() {
    let input = include_str!("validate_global_variables/fixtures/fragment-include-with-provided-argument.graphql");
    let expected = include_str!("validate_global_variables/fixtures/fragment-include-with-provided-argument.expected");
    test_fixture(transform_fixture, "fragment-include-with-provided-argument.graphql", "validate_global_variables/fixtures/fragment-include-with-provided-argument.expected", input, expected);
}

#[test]
fn fragment_with_undefined_variable_invalid() {
    let input = include_str!("validate_global_variables/fixtures/fragment-with-undefined-variable.invalid.graphql");
    let expected = include_str!("validate_global_variables/fixtures/fragment-with-undefined-variable.invalid.expected");
    test_fixture(transform_fixture, "fragment-with-undefined-variable.invalid.graphql", "validate_global_variables/fixtures/fragment-with-undefined-variable.invalid.expected", input, expected);
}

#[test]
fn query_with_undefined_variable_invalid() {
    let input = include_str!("validate_global_variables/fixtures/query-with-undefined-variable.invalid.graphql");
    let expected = include_str!("validate_global_variables/fixtures/query-with-undefined-variable.invalid.expected");
    test_fixture(transform_fixture, "query-with-undefined-variable.invalid.graphql", "validate_global_variables/fixtures/query-with-undefined-variable.invalid.expected", input, expected);
}

#[test]
fn query_with_variables() {
    let input = include_str!("validate_global_variables/fixtures/query-with-variables.graphql");
    let expected = include_str!("validate_global_variables/fixtures/query-with-variables.expected");
    test_fixture(transform_fixture, "query-with-variables.graphql", "validate_global_variables/fixtures/query-with-variables.expected", input, expected);
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @generated SignedSource<<ffc1a0363a0a6137108787e4e848f93d>>
 */

mod validate_global_variable_names;

use validate_global_variable_names::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn relayinternal_prefix_invalid() {
    let input = include_str!("validate_global_variable_names/fixtures/relayinternal_prefix_invalid.graphql");
    let expected = include_str!("validate_global_variable_names/fixtures/relayinternal_prefix_invalid.expected");
    test_fixture(transform_fixture, "relayinternal_prefix_invalid.graphql", "validate_global_variable_names/fixtures/relayinternal_prefix_invalid.expected", input, expected);
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @generated SignedSource<<c52f1e66f39dd95f89add376b2dab414>>
 */

mod validate_module_names;

use validate_module_names::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn fragment_with_valid_name() {
    let input = include_str!("validate_module_names/fixtures/fragment-with-valid-name.graphql");
    let expected = include_str!("validate_module_names/fixtures/fragment-with-valid-name.expected");
    test_fixture(transform_fixture, "fragment-with-valid-name.graphql", "validate_module_names/fixtures/fragment-with-valid-name.expected", input, expected);
}

#[test]
fn fragmentwithinvalidlycapitalizedname_invalid() {
    let input = include_str!("validate_module_names/fixtures/FragmentWithInvalidlyCapitalizedName.invalid.graphql");
    let expected = include_str!("validate_module_names/fixtures/FragmentWithInvalidlyCapitalizedName.invalid.expected");
    test_fixture(transform_fixture, "FragmentWithInvalidlyCapitalizedName.invalid.graphql", "validate_module_names/fixtures/FragmentWithInvalidlyCapitalizedName.invalid.expected", input, expected);
}

#[test]
fn fragmentwithinvalidname_invalid() {
    let input = include_str!("validate_module_names/fixtures/FragmentWithInvalidName.invalid.graphql");
    let expected = include_str!("validate_module_names/fixtures/FragmentWithInvalidName.invalid.expected");
    test_fixture(transform_fixture, "FragmentWithInvalidName.invalid.graphql", "validate_module_names/fixtures/FragmentWithInvalidName.invalid.expected", input, expected);
}

#[test]
fn fragmentwithvalidname() {
    let input = include_str!("validate_module_names/fixtures/FragmentWithValidName.graphql");
    let expected = include_str!("validate_module_names/fixtures/FragmentWithValidName.expected");
    test_fixture(transform_fixture, "FragmentWithValidName.graphql", "validate_module_names/fixtures/FragmentWithValidName.expected", input, expected);
}

#[test]
fn fragmentwithvalidname_android() {
    let input = include_str!("validate_module_names/fixtures/FragmentWithValidName.android.graphql");
    let expected = include_str!("validate_module_names/fixtures/FragmentWithValidName.android.expected");
    test_fixture(transform_fixture, "FragmentWithValidName.android.graphql", "validate_module_names/fixtures/FragmentWithValidName.android.expected", input, expected);
}

#[test]
fn fragmentwithvalidname_ios() {
    let input = include_str!("validate_module_names/fixtures/FragmentWithValidName.ios.graphql");
    let expected = include_str!("validate_module_names/fixtures/FragmentWithValidName.ios.expected");
    test_fixture(transform_fixture, "FragmentWithValidName.ios.graphql", "validate_module_names/fixtures/FragmentWithValidName.ios.expected", input, expected);
}

#[test]
fn fragmentwithvalidname_other_suffix() {
    let input = include_str!("validate_module_names/fixtures/FragmentWithValidName.other-suffix.graphql");
    let expected = include_str!("validate_module_names/fixtures/FragmentWithValidName.other-suffix.expected");
    test_fixture(transform_fixture, "FragmentWithValidName.other-suffix.graphql", "validate_module_names/fixtures/FragmentWithValidName.other-suffix.expected", input, expected);
}

#[test]
fn fragmentwithvalidname_other_suffix_ios_and_another() {
    let input = include_str!("validate_module_names/fixtures/FragmentWithValidName.other-suffix.ios.and-another.graphql");
    let expected = include_str!("validate_module_names/fixtures/FragmentWithValidName.other-suffix.ios.and-another.expected");
    test_fixture(transform_fixture, "FragmentWithValidName.other-suffix.ios.and-another.graphql", "validate_module_names/fixtures/FragmentWithValidName.other-suffix.ios.and-another.expected", input, expected);
}

#[test]
fn mutationwithinvalidname_invalid() {
    let input = include_str!("validate_module_names/fixtures/MutationWithInvalidName.invalid.graphql");
    let expected = include_str!("validate_module_names/fixtures/MutationWithInvalidName.invalid.expected");
    test_fixture(transform_fixture, "MutationWithInvalidName.invalid.graphql", "validate_module_names/fixtures/MutationWithInvalidName.invalid.expected", input, expected);
}

#[test]
fn mutationwithinvalidsuffix_invalid() {
    let input = include_str!("validate_module_names/fixtures/MutationWithInvalidSuffix.invalid.graphql");
    let expected = include_str!("validate_module_names/fixtures/MutationWithInvalidSuffix.invalid.expected");
    test_fixture(transform_fixture, "MutationWithInvalidSuffix.invalid.graphql", "validate_module_names/fixtures/MutationWithInvalidSuffix.invalid.expected", input, expected);
}

#[test]
fn mutationwithvalidname() {
    let input = include_str!("validate_module_names/fixtures/MutationWithValidName.graphql");
    let expected = include_str!("validate_module_names/fixtures/MutationWithValidName.expected");
    test_fixture(transform_fixture, "MutationWithValidName.graphql", "validate_module_names/fixtures/MutationWithValidName.expected", input, expected);
}

#[test]
fn querywithinvalidname_invalid() {
    let input = include_str!("validate_module_names/fixtures/QueryWithInvalidName.invalid.graphql");
    let expected = include_str!("validate_module_names/fixtures/QueryWithInvalidName.invalid.expected");
    test_fixture(transform_fixture, "QueryWithInvalidName.invalid.graphql", "validate_module_names/fixtures/QueryWithInvalidName.invalid.expected", input, expected);
}

#[test]
fn querywithinvalidsuffix_invalid() {
    let input = include_str!("validate_module_names/fixtures/QueryWithInvalidSuffix.invalid.graphql");
    let expected = include_str!("validate_module_names/fixtures/QueryWithInvalidSuffix.invalid.expected");
    test_fixture(transform_fixture, "QueryWithInvalidSuffix.invalid.graphql", "validate_module_names/fixtures/QueryWithInvalidSuffix.invalid.expected", input, expected);
}

#[test]
fn querywithvalidname() {
    let input = include_str!("validate_module_names/fixtures/QueryWithValidName.graphql");
    let expected = include_str!("validate_module_names/fixtures/QueryWithValidName.expected");
    test_fixture(transform_fixture, "QueryWithValidName.graphql", "validate_module_names/fixtures/QueryWithValidName.expected", input, expected);
}

#[test]
fn subscriptionwithinvalidname_invalid() {
    let input = include_str!("validate_module_names/fixtures/SubscriptionWithInvalidName.invalid.graphql");
    let expected = include_str!("validate_module_names/fixtures/SubscriptionWithInvalidName.invalid.expected");
    test_fixture(transform_fixture, "SubscriptionWithInvalidName.invalid.graphql", "validate_module_names/fixtures/SubscriptionWithInvalidName.invalid.expected", input, expected);
}

#[test]
fn subscriptionwithinvalidsuffix_invalid() {
    let input = include_str!("validate_module_names/fixtures/SubscriptionWithInvalidSuffix.invalid.graphql");
    let expected = include_str!("validate_module_names/fixtures/SubscriptionWithInvalidSuffix.invalid.expected");
    test_fixture(transform_fixture, "SubscriptionWithInvalidSuffix.invalid.graphql", "validate_module_names/fixtures/SubscriptionWithInvalidSuffix.invalid.expected", input, expected);
}

#[test]
fn subscriptionwithvalidname() {
    let input = include_str!("validate_module_names/fixtures/SubscriptionWithValidName.graphql");
    let expected = include_str!("validate_module_names/fixtures/SubscriptionWithValidName.expected");
    test_fixture(transform_fixture, "SubscriptionWithValidName.graphql", "validate_module_names/fixtures/SubscriptionWithValidName.expected", input, expected);
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @generated SignedSource<<db6d431b8538f21d76d1e7ecd0279ed7>>
 */

mod validate_no_double_underscore_alias;

use validate_no_double_underscore_alias::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn double_underscore_invalid() {
    let input = include_str!("validate_no_double_underscore_alias/fixtures/double_underscore.invalid.graphql");
    let expected = include_str!("validate_no_double_underscore_alias/fixtures/double_underscore.invalid.expected");
    test_fixture(transform_fixture, "double_underscore.invalid.graphql", "validate_no_double_underscore_alias/fixtures/double_underscore.invalid.expected", input, expected);
}

#[test]
fn non_alias() {
    let input = include_str!("validate_no_double_underscore_alias/fixtures/non_alias.graphql");
    let expected = include_str!("validate_no_double_underscore_alias/fixtures/non_alias.expected");
    test_fixture(transform_fixture, "non_alias.graphql", "validate_no_double_underscore_alias/fixtures/non_alias.expected", input, expected);
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @generated SignedSource<<82ae09fce8803e956efea1b568733995>>
 */

mod validate_no_unselectable_selections;

use validate_no_unselectable_selections::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn multiple_unselectables_invalid() {
    let input = include_str!("validate_no_unselectable_selections/fixtures/multiple-unselectables.invalid.graphql");
    let expected = include_str!("validate_no_unselectable_selections/fixtures/multiple-unselectables.invalid.expected");
    test_fixture(transform_fixture, "multiple-unselectables.invalid.graphql", "validate_no_unselectable_selections/fixtures/multiple-unselectables.invalid.expected", input, expected);
}

#[test]
fn unselectable_linked_field_invalid() {
    let input = include_str!("validate_no_unselectable_selections/fixtures/unselectable-linked-field.invalid.graphql");
    let expected = include_str!("validate_no_unselectable_selections/fixtures/unselectable-linked-field.invalid.expected");
    test_fixture(transform_fixture, "unselectable-linked-field.invalid.graphql", "validate_no_unselectable_selections/fixtures/unselectable-linked-field.invalid.expected", input, expected);
}

#[test]
fn unselectable_scalar_invalid() {
    let input = include_str!("validate_no_unselectable_selections/fixtures/unselectable-scalar.invalid.graphql");
    let expected = include_str!("validate_no_unselectable_selections/fixtures/unselectable-scalar.invalid.expected");
    test_fixture(transform_fixture, "unselectable-scalar.invalid.graphql", "validate_no_unselectable_selections/fixtures/unselectable-scalar.invalid.expected", input, expected);
}

#[test]
fn valid_selection() {
    let input = include_str!("validate_no_unselectable_selections/fixtures/valid-selection.graphql");
    let expected = include_str!("validate_no_unselectable_selections/fixtures/valid-selection.expected");
    test_fixture(transform_fixture, "valid-selection.graphql", "validate_no_unselectable_selections/fixtures/valid-selection.expected", input, expected);
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @generated SignedSource<<b1eb49ef4bf04fbb6fded75198376050>>
 */

mod validate_relay_directives;

use validate_relay_directives::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn mask_incompatible_type_invalid() {
    let input = include_str!("validate_relay_directives/fixtures/mask-incompatible-type-invalid.graphql");
    let expected = include_str!("validate_relay_directives/fixtures/mask-incompatible-type-invalid.expected");
    test_fixture(transform_fixture, "mask-incompatible-type-invalid.graphql", "validate_relay_directives/fixtures/mask-incompatible-type-invalid.expected", input, expected);
}

#[test]
fn mask_incompatible_type_invalid2() {
    let input = include_str!("validate_relay_directives/fixtures/mask-incompatible-type-invalid2.graphql");
    let expected = include_str!("validate_relay_directives/fixtures/mask-incompatible-type-invalid2.expected");
    test_fixture(transform_fixture, "mask-incompatible-type-invalid2.graphql", "validate_relay_directives/fixtures/mask-incompatible-type-invalid2.expected", input, expected);
}

#[test]
fn mask_incompatible_type_query_invalid() {
    let input = include_str!("validate_relay_directives/fixtures/mask-incompatible-type-query.invalid.graphql");
    let expected = include_str!("validate_relay_directives/fixtures/mask-incompatible-type-query.invalid.expected");
    test_fixture(transform_fixture, "mask-incompatible-type-query.invalid.graphql", "validate_relay_directives/fixtures/mask-incompatible-type-query.invalid.expected", input, expected);
}

#[test]
fn mask_mixed_local_root_invalid() {
    let input = include_str!("validate_relay_directives/fixtures/mask-mixed-local-root-invalid.graphql");
    let expected = include_str!("validate_relay_directives/fixtures/mask-mixed-local-root-invalid.expected");
    test_fixture(transform_fixture, "mask-mixed-local-root-invalid.graphql", "validate_relay_directives/fixtures/mask-mixed-local-root-invalid.expected", input, expected);
}

#[test]
fn mask_mixed_null() {
    let input = include_str!("validate_relay_directives/fixtures/mask-mixed-null.graphql");
    let expected = include_str!("validate_relay_directives/fixtures/mask-mixed-null.expected");
    test_fixture(transform_fixture, "mask-mixed-null.graphql", "validate_relay_directives/fixtures/mask-mixed-null.expected", input, expected);
}

#[test]
fn plural_fragment() {
    let input = include_str!("validate_relay_directives/fixtures/plural-fragment.graphql");
    let expected = include_str!("validate_relay_directives/fixtures/plural-fragment.expected");
    test_fixture(transform_fixture, "plural-fragment.graphql", "validate_relay_directives/fixtures/plural-fragment.expected", input, expected);
}

#[test]
fn plural_fragment_variables_invalid() {
    let input = include_str!("validate_relay_directives/fixtures/plural-fragment-variables.invalid.graphql");
    let expected = include_str!("validate_relay_directives/fixtures/plural-fragment-variables.invalid.expected");
    test_fixture(transform_fixture, "plural-fragment-variables.invalid.graphql", "validate_relay_directives/fixtures/plural-fragment-variables.invalid.expected", input, expected);
}

#[test]
fn unmasked_spread() {
    let input = include_str!("validate_relay_directives/fixtures/unmasked-spread.graphql");
    let expected = include_str!("validate_relay_directives/fixtures/unmasked-spread.expected");
    test_fixture(transform_fixture, "unmasked-spread.graphql", "validate_relay_directives/fixtures/unmasked-spread.expected", input, expected);
}

#[test]
fn unmasked_spread_with_argument_definition_invalid() {
    let input = include_str!("validate_relay_directives/fixtures/unmasked-spread-with-argument-definition.invalid.graphql");
    let expected = include_str!("validate_relay_directives/fixtures/unmasked-spread-with-argument-definition.invalid.expected");
    test_fixture(transform_fixture, "unmasked-spread-with-argument-definition.invalid.graphql", "validate_relay_directives/fixtures/unmasked-spread-with-argument-definition.invalid.expected", input, expected);
}

#[test]
fn unmasked_spread_with_directive_invalid() {
    let input = include_str!("validate_relay_directives/fixtures/unmasked-spread-with-directive.invalid.graphql");
    let expected = include_str!("validate_relay_directives/fixtures/unmasked-spread-with-directive.invalid.expected");
    test_fixture(transform_fixture, "unmasked-spread-with-directive.invalid.graphql", "validate_relay_directives/fixtures/unmasked-spread-with-directive.invalid.expected", input, expected);
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @generated SignedSource<<86341e77fc38860285a555f3430c105e>>
 */

mod validate_required_arguments;

use validate_required_arguments::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn argument_on_field() {
    let input = include_str!("validate_required_arguments/fixtures/argument-on-field.graphql");
    let expected = include_str!("validate_required_arguments/fixtures/argument-on-field.expected");
    test_fixture(transform_fixture, "argument-on-field.graphql", "validate_required_arguments/fixtures/argument-on-field.expected", input, expected);
}

#[test]
fn argument_on_linked_field() {
    let input = include_str!("validate_required_arguments/fixtures/argument-on-linked-field.graphql");
    let expected = include_str!("validate_required_arguments/fixtures/argument-on-linked-field.expected");
    test_fixture(transform_fixture, "argument-on-linked-field.graphql", "validate_required_arguments/fixtures/argument-on-linked-field.expected", input, expected);
}

#[test]
fn default_argument_on_field() {
    let input = include_str!("validate_required_arguments/fixtures/default-argument-on-field.graphql");
    let expected = include_str!("validate_required_arguments/fixtures/default-argument-on-field.expected");
    test_fixture(transform_fixture, "default-argument-on-field.graphql", "validate_required_arguments/fixtures/default-argument-on-field.expected", input, expected);
}

#[test]
fn missing_argument_on_directive_invalid() {
    let input = include_str!("validate_required_arguments/fixtures/missing-argument-on-directive.invalid.graphql");
    let expected = include_str!("validate_required_arguments/fixtures/missing-argument-on-directive.invalid.expected");
    test_fixture(transform_fixture, "missing-argument-on-directive.invalid.graphql", "validate_required_arguments/fixtures/missing-argument-on-directive.invalid.expected", input, expected);
}

#[test]
fn missing_argument_on_field_invalid() {
    let input = include_str!("validate_required_arguments/fixtures/missing-argument-on-field.invalid.graphql");
    let expected = include_str!("validate_required_arguments/fixtures/missing-argument-on-field.invalid.expected");
    test_fixture(transform_fixture, "missing-argument-on-field.invalid.graphql", "validate_required_arguments/fixtures/missing-argument-on-field.invalid.expected", input, expected);
}

#[test]
fn missing_argument_on_linked_field_in_inline_fragment_invalid() {
    let input = include_str!("validate_required_arguments/fixtures/missing-argument-on-linked-field-in-inline-fragment.invalid.graphql");
    let expected = include_str!("validate_required_arguments/fixtures/missing-argument-on-linked-field-in-inline-fragment.invalid.expected");
    test_fixture(transform_fixture, "missing-argument-on-linked-field-in-inline-fragment.invalid.graphql", "validate_required_arguments/fixtures/missing-argument-on-linked-field-in-inline-fragment.invalid.expected", input, expected);
}

#[test]
fn missing_argument_on_linked_field_invalid() {
    let input = include_str!("validate_required_arguments/fixtures/missing-argument-on-linked-field.invalid.graphql");
    let expected = include_str!("validate_required_arguments/fixtures/missing-argument-on-linked-field.invalid.expected");
    test_fixture(transform_fixture, "missing-argument-on-linked-field.invalid.graphql", "validate_required_arguments/fixtures/missing-argument-on-linked-field.invalid.expected", input, expected);
}

#[test]
fn missing_argument_on_linked_field_on_abstract_type_invalid() {
    let input = include_str!("validate_required_arguments/fixtures/missing-argument-on-linked-field-on-abstract-type.invalid.graphql");
    let expected = include_str!("validate_required_arguments/fixtures/missing-argument-on-linked-field-on-abstract-type.invalid.expected");
    test_fixture(transform_fixture, "missing-argument-on-linked-field-on-abstract-type.invalid.graphql", "validate_required_arguments/fixtures/missing-argument-on-linked-field-on-abstract-type.invalid.expected", input, expected);
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @generated SignedSource<<2e68a7fab154b5051d92bf6e0b537bb5>>
 */

mod validate_server_only_directives;

use validate_server_only_directives::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn fragment_with_client_fileds_inside_valid_fragments() {
    let input = include_str!("validate_server_only_directives/fixtures/fragment-with-client-fileds-inside-valid-fragments.graphql");
    let expected = include_str!("validate_server_only_directives/fixtures/fragment-with-client-fileds-inside-valid-fragments.expected");
    test_fixture(transform_fixture, "fragment-with-client-fileds-inside-valid-fragments.graphql", "validate_server_only_directives/fixtures/fragment-with-client-fileds-inside-valid-fragments.expected", input, expected);
}

#[test]
fn fragment_with_defer_on_client_invalid() {
    let input = include_str!("validate_server_only_directives/fixtures/fragment-with-defer-on-client.invalid.graphql");
    let expected = include_str!("validate_server_only_directives/fixtures/fragment-with-defer-on-client.invalid.expected");
    test_fixture(transform_fixture, "fragment-with-defer-on-client.invalid.graphql", "validate_server_only_directives/fixtures/fragment-with-defer-on-client.invalid.expected", input, expected);
}

#[test]
fn fragment_with_defer_on_fragment_with_only_client_fields_invalid() {
    let input = include_str!("validate_server_only_directives/fixtures/fragment-with-defer-on-fragment-with-only-client-fields.invalid.graphql");
    let expected = include_str!("validate_server_only_directives/fixtures/fragment-with-defer-on-fragment-with-only-client-fields.invalid.expected");
    test_fixture(transform_fixture, "fragment-with-defer-on-fragment-with-only-client-fields.invalid.graphql", "validate_server_only_directives/fixtures/fragment-with-defer-on-fragment-with-only-client-fields.invalid.expected", input, expected);
}

#[test]
fn fragment_with_stream_child_of_client_invalid() {
    let input = include_str!("validate_server_only_directives/fixtures/fragment-with-stream-child-of-client.invalid.graphql");
    let expected = include_str!("validate_server_only_directives/fixtures/fragment-with-stream-child-of-client.invalid.expected");
    test_fixture(transform_fixture, "fragment-with-stream-child-of-client.invalid.graphql", "validate_server_only_directives/fixtures/fragment-with-stream-child-of-client.invalid.expected", input, expected);
}

#[test]
fn fragment_with_stream_on_client_invalid() {
    let input = include_str!("validate_server_only_directives/fixtures/fragment-with-stream-on-client.invalid.graphql");
    let expected = include_str!("validate_server_only_directives/fixtures/fragment-with-stream-on-client.invalid.expected");
    test_fixture(transform_fixture, "fragment-with-stream-on-client.invalid.graphql", "validate_server_only_directives/fixtures/fragment-with-stream-on-client.invalid.expected", input, expected);
}

#[test]
fn match_() {
    let input = include_str!("validate_server_only_directives/fixtures/match_.graphql");
    let expected = include_str!("validate_server_only_directives/fixtures/match_.expected");
    test_fixture(transform_fixture, "match_.graphql", "validate_server_only_directives/fixtures/match_.expected", input, expected);
}

#[test]
fn module_on_child_of_client() {
    let input = include_str!("validate_server_only_directives/fixtures/module-on-child-of-client.graphql");
    let expected = include_str!("validate_server_only_directives/fixtures/module-on-child-of-client.expected");
    test_fixture(transform_fixture, "module-on-child-of-client.graphql", "validate_server_only_directives/fixtures/module-on-child-of-client.expected", input, expected);
}

#[test]
fn module_on_child_of_client_in_fragment() {
    let input = include_str!("validate_server_only_directives/fixtures/module-on-child-of-client-in-fragment.graphql");
    let expected = include_str!("validate_server_only_directives/fixtures/module-on-child-of-client-in-fragment.expected");
    test_fixture(transform_fixture, "module-on-child-of-client-in-fragment.graphql", "validate_server_only_directives/fixtures/module-on-child-of-client-in-fragment.expected", input, expected);
}

#[test]
fn nested_fragment_with_defer() {
    let input = include_str!("validate_server_only_directives/fixtures/nested-fragment-with-defer.graphql");
    let expected = include_str!("validate_server_only_directives/fixtures/nested-fragment-with-defer.expected");
    test_fixture(transform_fixture, "nested-fragment-with-defer.graphql", "validate_server_only_directives/fixtures/nested-fragment-with-defer.expected", input, expected);
}

#[test]
fn stream_connection_on_client_invalid() {
    let input = include_str!("validate_server_only_directives/fixtures/stream-connection-on-client.invalid.graphql");
    let expected = include_str!("validate_server_only_directives/fixtures/stream-connection-on-client.invalid.expected");
    test_fixture(transform_fixture, "stream-connection-on-client.invalid.graphql", "validate_server_only_directives/fixtures/stream-connection-on-client.invalid.expected", input, expected);
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @generated SignedSource<<7c97b400056e87e80acdee4470b99a05>>
 */

mod validate_static_args;

use validate_static_args::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn match_with_dynamic_arg_invalid() {
    let input = include_str!("validate_static_args/fixtures/match-with-dynamic-arg.invalid.graphql");
    let expected = include_str!("validate_static_args/fixtures/match-with-dynamic-arg.invalid.expected");
    test_fixture(transform_fixture, "match-with-dynamic-arg.invalid.graphql", "validate_static_args/fixtures/match-with-dynamic-arg.invalid.expected", input, expected);
}

#[test]
fn nonstatic_values_on_static_arg_invalid() {
    let input = include_str!("validate_static_args/fixtures/nonstatic-values-on-static-arg.invalid.graphql");
    let expected = include_str!("validate_static_args/fixtures/nonstatic-values-on-static-arg.invalid.expected");
    test_fixture(transform_fixture, "nonstatic-values-on-static-arg.invalid.graphql", "validate_static_args/fixtures/nonstatic-values-on-static-arg.invalid.expected", input, expected);
}

#[test]
fn required_with_dynamic_arg_invalid() {
    let input = include_str!("validate_static_args/fixtures/required-with-dynamic-arg.invalid.graphql");
    let expected = include_str!("validate_static_args/fixtures/required-with-dynamic-arg.invalid.expected");
    test_fixture(transform_fixture, "required-with-dynamic-arg.invalid.graphql", "validate_static_args/fixtures/required-with-dynamic-arg.invalid.expected", input, expected);
}

#[test]
fn static_only_for_constants() {
    let input = include_str!("validate_static_args/fixtures/static-only-for-constants.graphql");
    let expected = include_str!("validate_static_args/fixtures/static-only-for-constants.expected");
    test_fixture(transform_fixture, "static-only-for-constants.graphql", "validate_static_args/fixtures/static-only-for-constants.expected", input, expected);
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @generated SignedSource<<620255d5fdc8dee833f3b68dc61e8fa8>>
 */

mod validate_unused_variables;

use validate_unused_variables::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn fragment_with_root_arguments() {
    let input = include_str!("validate_unused_variables/fixtures/fragment-with-root-arguments.graphql");
    let expected = include_str!("validate_unused_variables/fixtures/fragment-with-root-arguments.expected");
    test_fixture(transform_fixture, "fragment-with-root-arguments.graphql", "validate_unused_variables/fixtures/fragment-with-root-arguments.expected", input, expected);
}

#[test]
fn practically_unused_but_actually_used_variables() {
    let input = include_str!("validate_unused_variables/fixtures/practically-unused-but-actually-used-variables.graphql");
    let expected = include_str!("validate_unused_variables/fixtures/practically-unused-but-actually-used-variables.expected");
    test_fixture(transform_fixture, "practically-unused-but-actually-used-variables.graphql", "validate_unused_variables/fixtures/practically-unused-but-actually-used-variables.expected", input, expected);
}

#[test]
fn query_with_invalid_error_suppression() {
    let input = include_str!("validate_unused_variables/fixtures/query-with-invalid-error-suppression.graphql");
    let expected = include_str!("validate_unused_variables/fixtures/query-with-invalid-error-suppression.expected");
    test_fixture(transform_fixture, "query-with-invalid-error-suppression.graphql", "validate_unused_variables/fixtures/query-with-invalid-error-suppression.expected", input, expected);
}

#[test]
fn query_with_unused_root_variable_shadowed_by_local_invalid() {
    let input = include_str!("validate_unused_variables/fixtures/query-with-unused-root-variable-shadowed-by-local.invalid.graphql");
    let expected = include_str!("validate_unused_variables/fixtures/query-with-unused-root-variable-shadowed-by-local.invalid.expected");
    test_fixture(transform_fixture, "query-with-unused-root-variable-shadowed-by-local.invalid.graphql", "validate_unused_variables/fixtures/query-with-unused-root-variable-shadowed-by-local.invalid.expected", input, expected);
}

#[test]
fn query_with_unused_variable_error_suppressed() {
    let input = include_str!("validate_unused_variables/fixtures/query-with-unused-variable-error-suppressed.graphql");
    let expected = include_str!("validate_unused_variables/fixtures/query-with-unused-variable-error-suppressed.expected");
    test_fixture(transform_fixture, "query-with-unused-variable-error-suppressed.graphql", "validate_unused_variables/fixtures/query-with-unused-variable-error-suppressed.expected", input, expected);
}

#[test]
fn query_with_unused_variable_invalid() {
    let input = include_str!("validate_unused_variables/fixtures/query-with-unused-variable.invalid.graphql");
    let expected = include_str!("validate_unused_variables/fixtures/query-with-unused-variable.invalid.expected");
    test_fixture(transform_fixture, "query-with-unused-variable.invalid.graphql", "validate_unused_variables/fixtures/query-with-unused-variable.invalid.expected", input, expected);
}

#[test]
fn query_with_variables_shadowed_by_local_variable_and_used_as_root_variable() {
    let input = include_str!("validate_unused_variables/fixtures/query-with-variables-shadowed-by-local-variable-and-used-as-root-variable.graphql");
    let expected = include_str!("validate_unused_variables/fixtures/query-with-variables-shadowed-by-local-variable-and-used-as-root-variable.expected");
    test_fixture(transform_fixture, "query-with-variables-shadowed-by-local-variable-and-used-as-root-variable.graphql", "validate_unused_variables/fixtures/query-with-variables-shadowed-by-local-variable-and-used-as-root-variable.expected", input, expected);
}

#[test]
fn variable_in_the_complex_object_list() {
    let input = include_str!("validate_unused_variables/fixtures/variable-in-the-complex-object-list.graphql");
    let expected = include_str!("validate_unused_variables/fixtures/variable-in-the-complex-object-list.expected");
    test_fixture(transform_fixture, "variable-in-the-complex-object-list.graphql", "validate_unused_variables/fixtures/variable-in-the-complex-object-list.expected", input, expected);
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use common::FeatureFlag;
use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::apply_fragment_arguments;
use relay_transforms::provided_variable_fragment_transform;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        let program = provided_variable_fragment_transform(program)?;
        apply_fragment_arguments(&program, false, &FeatureFlag::Enabled, &Default::default())
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::TEST_SCHEMA;
use relay_transforms::validate_assignable_directive;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir_result = build(&TEST_SCHEMA, &ast.definitions);
    let ir = ir_result
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let program = Program::from_definitions(Arc::clone(&TEST_SCHEMA), ir);
    validate_assignable_directive(&program)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use common::DiagnosticsResult;
use fixture_tests::Fixture;
use graphql_ir::Program;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::transform_assignable_fragment_spreads_in_regular_queries;

fn transform(program: &Program) -> DiagnosticsResult<Program> {
    transform_assignable_fragment_spreads_in_regular_queries(program)
}

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, transform)
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use graphql_text_printer::print_fragment;
use graphql_text_printer::print_operation;
use graphql_text_printer::PrinterOptions;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::client_edges;
use relay_transforms::relay_resolvers;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();
    if let [base, extensions] = parts.as_slice() {
        let source_location = SourceLocationKey::standalone(fixture.file_name);
        let ast = parse_executable(base, source_location).unwrap();
        let schema = get_test_schema_with_extensions(extensions);
        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);

        let mut next_program = client_edges(&program, &Default::default())
            .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

        next_program = relay_resolvers(&next_program, true)
            .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

        let printer_options = PrinterOptions {
            debug_directive_data: true,
            ..Default::default()
        };

        let mut printed = next_program
            .operations()
            .map(|def| print_operation(&schema, def, printer_options.clone()))
            .chain(
                next_program
                    .fragments()
                    .map(|def| print_fragment(&schema, def, printer_options.clone())),
            )
            .collect::<Vec<_>>();
        printed.sort();

        Ok(printed.join("\n\n"))
    } else {
        panic!("Expected exactly one %extensions% section marker.")
    }
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_text_printer::print_fragment;
use graphql_text_printer::print_operation;
use graphql_text_printer::PrinterOptions;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::client_extensions;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();
    if let [base, extensions] = parts.as_slice() {
        let source_location = SourceLocationKey::standalone(fixture.file_name);
        let ast = parse_executable(base, source_location).unwrap();
        let schema = get_test_schema_with_extensions(extensions);
        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);
        let next_program = client_extensions(&program);

        let printer_options = PrinterOptions {
            debug_directive_data: true,
            ..Default::default()
        };

        let mut printed = next_program
            .operations()
            .map(|def| print_operation(&schema, def, printer_options.clone()))
            .chain(
                next_program
                    .fragments()
                    .map(|def| print_fragment(&schema, def, printer_options.clone())),
            )
            .collect::<Vec<_>>();
        printed.sort();
        Ok(printed.join("\n\n"))
    } else {
        panic!("Expected exactly one %extensions% section marker.")
    }
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_text_printer::print_fragment;
use graphql_text_printer::print_operation;
use graphql_text_printer::PrinterOptions;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::client_extensions_abstract_types;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();
    if let [base, extensions] = parts.as_slice() {
        let source_location = SourceLocationKey::standalone(fixture.file_name);
        let ast = parse_executable(base, source_location).unwrap();
        let schema = get_test_schema_with_extensions(extensions);
        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);
        let next_program = client_extensions_abstract_types(&program);

        let printer_options = PrinterOptions {
            debug_directive_data: true,
            ..Default::default()
        };

        let mut printed = next_program
            .operations()
            .map(|def| print_operation(&schema, def, printer_options.clone()))
            .chain(
                next_program
                    .fragments()
                    .map(|def| print_fragment(&schema, def, printer_options.clone())),
            )
            .collect::<Vec<_>>();
        printed.sort();
        Ok(printed.join("\n\n"))
    } else {
        panic!("Expected exactly one %extensions% section marker.")
    }
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::transform_declarative_connection;
use relay_transforms::ConnectionInterface;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        transform_declarative_connection(program, &ConnectionInterface::default())
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::transform_defer_stream;
use relay_transforms::unwrap_custom_directive_selection;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        let program = transform_defer_stream(program)?;
        let program = unwrap_custom_directive_selection(&program);
        Ok(program)
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::collections::HashMap;
use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use intern::intern;
use relay_config::NonNodeIdFieldsConfig;
use relay_config::SchemaConfig;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::disallow_non_node_id_fields;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();

    if let [base, extensions] = parts.as_slice() {
        let source_location = SourceLocationKey::standalone(fixture.file_name);
        let ast = parse_executable(base, source_location).unwrap();
        let schema = get_test_schema_with_extensions(extensions);

        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);

        let schema_config = SchemaConfig {
            non_node_id_fields: Some(NonNodeIdFieldsConfig {
                allowed_id_types: {
                    let mut mappings = HashMap::new();

                    // Add types to allow here from `testschema.graphql`
                    mappings.insert(intern!("NonNode"), intern!("String"));

                    // Add test types that should also be allowed here
                    mappings.insert(
                        intern!("UserWithAllowedCustomIDType"),
                        intern!("AllowedCustomIDType"),
                    );

                    mappings
                },
            }),
            ..Default::default()
        };

        disallow_non_node_id_fields(&program, &schema_config)
            .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

        Ok("OK".to_owned())
    } else {
        panic!("Expected exactly one %extensions% section marker.")
    }
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::get_test_schema;
use relay_transforms::disallow_reserved_aliases;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);
    let schema = get_test_schema();
    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir = build(&schema, &ast.definitions).unwrap();
    let program = Program::from_definitions(schema, ir);
    disallow_reserved_aliases(&program, &Default::default())
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::get_test_schema;
use relay_transforms::disallow_typename_on_root;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);
    let schema = get_test_schema();
    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir = build(&schema, &ast.definitions).unwrap();
    let program = Program::from_definitions(schema, ir);
    disallow_typename_on_root(&program)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use graphql_text_printer::print_fragment;
use graphql_text_printer::print_operation;
use graphql_text_printer::PrinterOptions;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::flatten;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);
    let ast = parse_executable(fixture.content, source_location)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;
    let schema = get_test_schema_with_extensions(
        r#"
directive @serverInlineDirective on INLINE_FRAGMENT"#,
    );
    let ir = build(&schema, &ast.definitions)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;
    let mut context = Program::from_definitions(Arc::clone(&schema), ir);
    flatten(
        &mut context,
        !fixture.content.contains("%for_printing%"),
        false,
    )
    .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let printer_options = PrinterOptions {
        debug_directive_data: true,
        ..Default::default()
    };

    let mut printed_queries = context
        .operations()
        .map(|def| print_operation(&schema, def, printer_options.clone()))
        .collect::<Vec<_>>();

    let mut printed = context
        .fragments()
        .map(|def| print_fragment(&schema, def, printer_options.clone()))
        .collect::<Vec<_>>();
    printed.append(&mut printed_queries);
    printed.sort();
    Ok(printed.join("\n\n"))
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use common::FeatureFlag;
use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::fragment_alias_directive;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        fragment_alias_directive(program, &FeatureFlag::Enabled)
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use common::FeatureFlags;
use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::generate_data_driven_dependency_metadata;
use relay_transforms::transform_match;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        let flags = FeatureFlags::default();
        let program = transform_match(program, &flags, Default::default())?;
        let program = generate_data_driven_dependency_metadata(&program);
        Ok(program)
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::generate_id_field;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        Ok(generate_id_field(program, &Default::default()))
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::generate_live_query_metadata;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, generate_live_query_metadata)
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_config::SchemaConfig;
use relay_transforms::generate_relay_resolvers_operations_for_nested_objects;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        generate_relay_resolvers_operations_for_nested_objects(program, &SchemaConfig::default())
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::generate_typename;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| Ok(generate_typename(program, false)))
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::inline_data_fragment;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, inline_data_fragment)
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::inline_fragments;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        let next_program = inline_fragments(program);
        assert_eq!(next_program.fragments().count(), 0);
        assert_eq!(
            next_program.operations().count(),
            program.operations().count()
        );
        Ok(next_program)
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_text_printer::print_fragment;
use graphql_text_printer::PrinterOptions;
use relay_test_schema::get_test_schema;
use relay_transforms::mask;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);
    let schema = get_test_schema();
    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir = build(&schema, &ast.definitions).unwrap();
    let program = Program::from_definitions(Arc::clone(&schema), ir);
    let next_program = &mask(&program);

    assert_eq!(
        next_program.fragments().count(),
        program.fragments().count()
    );

    let printer_options = PrinterOptions {
        debug_directive_data: true,
        ..Default::default()
    };
    let mut printed = next_program
        .fragments()
        .map(|def| {
            format!(
                "{}\n{:#?}",
                print_fragment(&schema, def, printer_options.clone()),
                def.used_global_variables
            )
        })
        .collect::<Vec<_>>();
    printed.sort();

    Ok(printed.join("\n\n"))
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use common::FeatureFlags;
use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::transform_match;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let flags = FeatureFlags::default();
    apply_transform_for_test(fixture, |program| {
        transform_match(program, &flags, Default::default())
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use common::FeatureFlags;
use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_config::DynamicModuleProvider;
use relay_config::ModuleImportConfig;
use relay_transforms::transform_match;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let flags = FeatureFlags::default();
    let module_import_config = ModuleImportConfig {
        dynamic_module_provider: Some(DynamicModuleProvider::JSResource),
    };
    apply_transform_for_test(fixture, |program| {
        transform_match(program, &flags, module_import_config)
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::provided_variable_fragment_transform;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        provided_variable_fragment_transform(program)
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::transform_connections;
use relay_transforms::transform_refetchable_fragment;
use relay_transforms::ConnectionInterface;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        let program = transform_connections(program, &ConnectionInterface::default());
        let base_fragments = Default::default();
        transform_refetchable_fragment(&program, &Default::default(), &base_fragments, false)
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use common::FeatureFlag;
use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::relay_actor_change_transform;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        relay_actor_change_transform(program, &FeatureFlag::Enabled)
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::Diagnostic;
use common::FeatureFlag;
use common::SourceLocationKey;
use common::TextSource;
use fixture_tests::Fixture;
use graphql_cli::DiagnosticPrinter;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_text_printer::print_fragment;
use graphql_text_printer::print_operation;
use graphql_text_printer::PrinterOptions;
use relay_test_schema::get_test_schema_with_located_extensions;
use relay_transforms::fragment_alias_directive;
use relay_transforms::relay_resolvers;
use relay_transforms::validate_resolver_fragments;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();
    if let [base, extensions] = parts.as_slice() {
        let graphql_location = SourceLocationKey::embedded(fixture.file_name, 0);
        let extension_location = SourceLocationKey::embedded(fixture.file_name, 1);

        let ast = parse_executable(base, graphql_location).unwrap();
        let schema = get_test_schema_with_located_extensions(extensions, extension_location);
        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);

        validate_resolver_fragments(&program)
            .map_err(|diagnostics| diagnostics_to_sorted_string(base, extensions, &diagnostics))?;

        // Run `fragment_alias_directive` first because we want to ensure we
        // correctly generate paths for named inline fragment spreads.
        let next_program = fragment_alias_directive(&program, &FeatureFlag::Enabled)
            .and_then(|program| relay_resolvers(&program, true))
            .map_err(|diagnostics| diagnostics_to_sorted_string(base, extensions, &diagnostics))?;

        let printer_options = PrinterOptions {
            debug_directive_data: true,
            ..Default::default()
        };
        let mut printed = next_program
            .operations()
            .map(|def| print_operation(&schema, def, printer_options.clone()))
            .chain(
                next_program
                    .fragments()
                    .map(|def| print_fragment(&schema, def, printer_options.clone())),
            )
            .collect::<Vec<_>>();
        printed.sort();

        Ok(printed.join("\n\n"))
    } else {
        panic!("Expected exactly one %extensions% section marker.")
    }
}

pub fn diagnostics_to_sorted_string(
    source: &str,
    extensions: &str,
    diagnostics: &[Diagnostic],
) -> String {
    let printer = DiagnosticPrinter::new(|source_location| match source_location {
        SourceLocationKey::Embedded { index, .. } => {
            Some(TextSource::from_whole_document(match index {
                0 => source,
                1 => extensions,
                _ => panic!("Expected index to be 0 or 1"),
            }))
        }
        SourceLocationKey::Standalone { .. } => None,
        SourceLocationKey::Generated => None,
    });
    let mut printed = diagnostics
        .iter()
        .map(|diagnostic| printer.diagnostic_to_string(diagnostic))
        .collect::<Vec<_>>();
    printed.sort();
    printed.join("\n\n")
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use graphql_text_printer::print_fragment;
use graphql_text_printer::print_operation;
use graphql_text_printer::PrinterOptions;
use regex::Regex;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::generate_test_operation_metadata;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();

    if let [base, extensions] = parts.as_slice() {
        let source_location = SourceLocationKey::standalone(fixture.file_name);
        let ast = parse_executable(base, source_location).unwrap();
        let schema = get_test_schema_with_extensions(extensions);

        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);

        let test_path_regex = Some(Regex::new(r#"^test"#).unwrap());

        let next_program = generate_test_operation_metadata(&program, &test_path_regex)
            .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

        let printer_options = PrinterOptions {
            debug_directive_data: true,
            ..Default::default()
        };

        let mut printed = next_program
            .operations()
            .map(|def| print_operation(&schema, def, printer_options.clone()))
            .chain(
                next_program
                    .fragments()
                    .map(|def| print_fragment(&schema, def, printer_options.clone())),
            )
            .collect::<Vec<_>>();
        printed.sort();
        Ok(printed.join("\n\n"))
    } else {
        panic!("Expected exactly one %extensions% section marker.")
    }
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use common::DiagnosticsResult;
use common::FeatureFlag;
use fixture_tests::Fixture;
use graphql_ir::Program;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::fragment_alias_directive;
use relay_transforms::required_directive;

fn transform(program: &Program) -> DiagnosticsResult<Program> {
    required_directive(&fragment_alias_directive(program, &FeatureFlag::Enabled)?)
}

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, transform)
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_text_printer::print_fragment;
use graphql_text_printer::print_operation;
use graphql_text_printer::PrinterOptions;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::skip_client_extensions;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();
    if let [base, extensions] = parts.as_slice() {
        let source_location = SourceLocationKey::standalone(fixture.file_name);
        let ast = parse_executable(base, source_location).unwrap();
        let schema = get_test_schema_with_extensions(extensions);
        let ir = build(&schema, &ast.definitions).unwrap();
        let context = Program::from_definitions(Arc::clone(&schema), ir);
        let next_context = skip_client_extensions(&context);

        let printer_options = PrinterOptions {
            debug_directive_data: true,
            ..Default::default()
        };
        let mut printed = next_context
            .operations()
            .map(|def| print_operation(&schema, def, printer_options.clone()))
            .chain(
                next_context
                    .fragments()
                    .map(|def| print_fragment(&schema, def, printer_options.clone())),
            )
            .collect::<Vec<_>>();
        printed.sort();
        Ok(printed.join("\n\n"))
    } else {
        panic!("Expected exactly one %extensions% section marker.")
    }
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_text_printer::print_operation;
use graphql_text_printer::PrinterOptions;
use relay_test_schema::get_test_schema;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::inline_fragments;
use relay_transforms::skip_redundant_nodes;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();
    let printer_options = PrinterOptions {
        debug_directive_data: true,
        ..Default::default()
    };
    let mut printed = if let [base, extensions] = parts.as_slice() {
        let ast = parse_executable(base, source_location).unwrap();
        let schema = get_test_schema_with_extensions(extensions);
        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);
        let next_program = skip_redundant_nodes(&inline_fragments(&program));
        next_program
            .operations()
            .map(|def| print_operation(&schema, def, printer_options.clone()))
            .collect::<Vec<_>>()
    } else {
        let schema = get_test_schema();
        let ast = parse_executable(fixture.content, source_location).unwrap();
        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);
        let next_program = skip_redundant_nodes(&inline_fragments(&program));
        next_program
            .operations()
            .map(|def| print_operation(&schema, def, printer_options.clone()))
            .collect::<Vec<_>>()
    };

    printed.sort();
    Ok(printed.join("\n\n"))
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::skip_unreachable_node_strict;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, skip_unreachable_node_strict)
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::validate_operation_variables;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| validate_operation_variables(program))
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::sort_selections;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| {
        let next_program = sort_selections(program);
        assert_eq!(
            next_program.fragments().count(),
            program.fragments().count()
        );
        Ok(next_program)
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::transform_subscriptions;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |program| transform_subscriptions(program))
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use graphql_text_printer::print_fragment;
use graphql_text_printer::print_operation;
use graphql_text_printer::PrinterOptions;
use relay_test_schema::get_test_schema;
use relay_transforms::transform_connections;
use relay_transforms::validate_connections;
use relay_transforms::ConnectionInterface;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let schema = get_test_schema();

    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir = build(&schema, &ast.definitions)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let program = Program::from_definitions(Arc::clone(&schema), ir);

    let connection_interface = ConnectionInterface::default();

    validate_connections(&program, &connection_interface)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let next_program = transform_connections(&program, &connection_interface);

    let printer_options = PrinterOptions {
        debug_directive_data: true,
        ..Default::default()
    };
    let mut printed = next_program
        .operations()
        .map(|def| print_operation(&schema, def, printer_options.clone()))
        .chain(
            next_program
                .fragments()
                .map(|def| print_fragment(&schema, def, printer_options.clone())),
        )
        .collect::<Vec<_>>();
    printed.sort();
    Ok(printed.join("\n\n"))
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::get_test_schema;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::validate_updatable_directive;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let mut parts = fixture.content.split("%extensions%");
    let base = parts.next().expect("Pre-extension content required");
    let maybe_extensions = parts.next();
    let schema = if let Some(extensions) = maybe_extensions {
        get_test_schema_with_extensions(extensions)
    } else {
        get_test_schema()
    };

    let ast = parse_executable(base, source_location).unwrap();
    let ir_result = build(&schema, &ast.definitions);
    let ir = ir_result
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let program = Program::from_definitions(Arc::clone(&schema), ir);
    validate_updatable_directive(&program)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::TEST_SCHEMA;
use relay_transforms::validate_updatable_fragment_spread;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir_result = build(&TEST_SCHEMA, &ast.definitions);
    let ir = ir_result
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let program = Program::from_definitions(Arc::clone(&TEST_SCHEMA), ir);
    validate_updatable_fragment_spread(&program)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::TEST_SCHEMA;
use relay_transforms::validate_connections;
use relay_transforms::ConnectionInterface;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir_result = build(&TEST_SCHEMA, &ast.definitions);
    let ir = ir_result
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let program = Program::from_definitions(Arc::clone(&TEST_SCHEMA), ir);
    validate_connections(&program, &ConnectionInterface::default())
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::validate_connections;
use relay_transforms::ConnectionInterface;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();

    if let [base, extensions] = parts.as_slice() {
        let source_location = SourceLocationKey::standalone(fixture.file_name);
        let ast = parse_executable(base, source_location).unwrap();
        let schema = get_test_schema_with_extensions(extensions);

        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);
        validate_connections(&program, &ConnectionInterface::default())
            .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

        Ok("OK".to_string())
    } else {
        panic!("Expected exactly one %extensions% section marker.")
    }
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::deprecated_fields;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();

    if let [base, extensions] = parts.as_slice() {
        let source_location = SourceLocationKey::standalone(fixture.file_name);
        let ast = parse_executable(base, source_location).unwrap();
        let schema = get_test_schema_with_extensions(extensions);

        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);
        let warnings = deprecated_fields(&schema, &program)
            .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

        Ok(diagnostics_to_sorted_string(fixture.content, &warnings))
    } else {
        panic!("Expected exactly one %extensions% section marker.")
    }
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use common::TextSource;
use fixture_tests::Fixture;
use graphql_cli::DiagnosticPrinter;
use graphql_ir::build_ir_with_extra_features;
use graphql_ir::BuilderOptions;
use graphql_ir::FragmentVariablesSemantic;
use graphql_ir::Program;
use graphql_ir::RelayMode;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::TEST_SCHEMA;
use relay_transforms::validate_global_variables;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir_result = build_ir_with_extra_features(
        &TEST_SCHEMA,
        &ast.definitions,
        &BuilderOptions {
            allow_undefined_fragment_spreads: false,
            fragment_variables_semantic: FragmentVariablesSemantic::PassedValue,
            relay_mode: Some(RelayMode),
            default_anonymous_operation_name: None,
        },
    );

    let ir = match ir_result {
        Ok(res) => res,
        Err(errors) => {
            let mut errs = errors
                .into_iter()
                .map(|err| {
                    let printer = DiagnosticPrinter::new(|_| {
                        Some(TextSource::from_whole_document(fixture.content.to_string()))
                    });
                    printer.diagnostic_to_string(&err)
                })
                .collect::<Vec<_>>();
            errs.sort();
            return Err(errs.join("\n\n"));
        }
    };

    let program = Program::from_definitions(Arc::clone(&TEST_SCHEMA), ir);
    validate_global_variables(&program)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::TEST_SCHEMA;
use relay_transforms::validate_global_variable_names;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir = build(&TEST_SCHEMA, &ast.definitions)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let program = Program::from_definitions(Arc::clone(&TEST_SCHEMA), ir);
    validate_global_variable_names(&program)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::TEST_SCHEMA;
use relay_transforms::validate_module_names;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir = build(&TEST_SCHEMA, &ast.definitions)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let program = Program::from_definitions(Arc::clone(&TEST_SCHEMA), ir);
    validate_module_names(&program)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::TEST_SCHEMA;
use relay_transforms::validate_no_double_underscore_alias;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir_result = build(&TEST_SCHEMA, &ast.definitions);
    let ir = ir_result
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let program = Program::from_definitions(Arc::clone(&TEST_SCHEMA), ir);
    validate_no_double_underscore_alias(&program)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use fixture_tests::Fixture;
use graphql_test_helpers::apply_transform_for_test;
use relay_transforms::validate_no_unselectable_selections;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    apply_transform_for_test(fixture, |p| {
        validate_no_unselectable_selections(p, &Default::default())?;
        Ok(p.clone())
    })
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::get_test_schema;
use relay_transforms::validate_relay_directives;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let schema = get_test_schema();
    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir = build(&schema, &ast.definitions)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let program = Program::from_definitions(schema, ir);
    validate_relay_directives(&program)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::TEST_SCHEMA;
use relay_transforms::validate_required_arguments;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir = build(&TEST_SCHEMA, &ast.definitions)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let program = Program::from_definitions(Arc::clone(&TEST_SCHEMA), ir);
    validate_required_arguments(&program)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::validate_server_only_directives;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();

    if let [base, extensions] = parts.as_slice() {
        let source_location = SourceLocationKey::standalone(fixture.file_name);
        let ast = parse_executable(base, source_location).unwrap();
        let schema = get_test_schema_with_extensions(extensions);

        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);
        validate_server_only_directives(&program)
            .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

        Ok("OK".to_owned())
    } else {
        panic!("Expected exactly one %extensions% section marker.")
    }
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::get_test_schema_with_extensions;
use relay_transforms::validate_static_args;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let parts: Vec<_> = fixture.content.split("%extensions%").collect();

    if let [base, extensions] = parts.as_slice() {
        let source_location = SourceLocationKey::standalone(fixture.file_name);
        let ast = parse_executable(base, source_location).unwrap();
        let schema = get_test_schema_with_extensions(extensions);

        let ir = build(&schema, &ast.definitions).unwrap();
        let program = Program::from_definitions(Arc::clone(&schema), ir);
        validate_static_args(&program)
            .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

        Ok("OK".to_owned())
    } else {
        panic!("Expected exactly one %extensions% section marker.")
    }
}


/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

use std::sync::Arc;

use common::SourceLocationKey;
use fixture_tests::Fixture;
use graphql_ir::build;
use graphql_ir::Program;
use graphql_syntax::parse_executable;
use graphql_test_helpers::diagnostics_to_sorted_string;
use relay_test_schema::TEST_SCHEMA;
use relay_transforms::validate_unused_variables;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
    let source_location = SourceLocationKey::standalone(fixture.file_name);

    let ast = parse_executable(fixture.content, source_location).unwrap();
    let ir = build(&TEST_SCHEMA, &ast.definitions)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    let program = Program::from_definitions(Arc::clone(&TEST_SCHEMA), ir);
    validate_unused_variables(&program)
        .map_err(|diagnostics| diagnostics_to_sorted_string(fixture.content, &diagnostics))?;

    Ok("OK".to_owned())
}