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

'use strict';

const {Validator} = require('graphql-compiler');

import type {GraphQLField, ValidationContext} from 'graphql';

const {GLOBAL_RULES, LOCAL_RULES, validate} = Validator;

function DisallowIdAsAliasValidationRule(context: ValidationContext) {
  return {
    Field(field: GraphQLField<*, *>): void {
      if (
        /* $FlowFixMe(>=0.68.0 site=react_native_fb,react_native_oss) This
         * comment suppresses an error found when Flow v0.68 was deployed. To
         * see the error delete this comment and run Flow. */
        field.alias &&
        field.alias.value === 'id' &&
        /* $FlowFixMe(>=0.68.0 site=react_native_fb,react_native_oss) This
         * comment suppresses an error found when Flow v0.68 was deployed. To
         * see the error delete this comment and run Flow. */
        field.name.value !== 'id'
      ) {
        throw new Error(
          'RelayValidator: Relay does not allow aliasing fields to `id`. ' +
            'This name is reserved for the globally unique `id` field on ' +
            '`Node`.',
        );
      }
    },
  };
}

const relayGlobalRules = GLOBAL_RULES;

const relayLocalRules = [...LOCAL_RULES, DisallowIdAsAliasValidationRule];

module.exports = {
  GLOBAL_RULES: relayGlobalRules,
  LOCAL_RULES: relayLocalRules,
  validate,
};

@@ -189,16 +189,29 @@
  * @flow
+ strict-local
 %0A * @for
@@ -297,28 +297,25 @@
 t type %7B
-GraphQL
 Field
+Node
 , Valida
@@ -505,26 +505,17 @@
 ld: 
-GraphQLField%3C*, *%3E
+FieldNode
 ): v
@@ -543,490 +543,60 @@
     
-/* $FlowFixMe(%3E=0.68.0 site=react_native_fb,react_native_oss) This%0A         * comment suppresses an error found when Flow v0.68 was deployed. To%0A         * see the error delete this comment and run Flow. */%0A        field.alias &&%0A        field.alias.value === 'id' &&%0A        /* $FlowFixMe(%3E=0.68.0 site=react_native_fb,react_native_oss) This%0A         * comment suppresses an error found when Flow v0.68 was deployed. To%0A         * see the error delete this comment and run Flow. */
+field.alias &&%0A        field.alias.value === 'id' &&
 %0A   

fix FloxFixMe in RelayValidator