Initial Sample.
This commit is contained in:
		
							
								
								
									
										15
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoDeprecatedCustomRule.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoDeprecatedCustomRule.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
import type { ASTVisitor } from '../../../language/visitor';
 | 
			
		||||
import type { ValidationContext } from '../../ValidationContext';
 | 
			
		||||
/**
 | 
			
		||||
 * No deprecated
 | 
			
		||||
 *
 | 
			
		||||
 * A GraphQL document is only valid if all selected fields and all used enum values have not been
 | 
			
		||||
 * deprecated.
 | 
			
		||||
 *
 | 
			
		||||
 * Note: This rule is optional and is not part of the Validation section of the GraphQL
 | 
			
		||||
 * Specification. The main purpose of this rule is detection of deprecated usages and not
 | 
			
		||||
 * necessarily to forbid their use when querying a service.
 | 
			
		||||
 */
 | 
			
		||||
export declare function NoDeprecatedCustomRule(
 | 
			
		||||
  context: ValidationContext,
 | 
			
		||||
): ASTVisitor;
 | 
			
		||||
							
								
								
									
										131
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoDeprecatedCustomRule.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoDeprecatedCustomRule.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,131 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
Object.defineProperty(exports, '__esModule', {
 | 
			
		||||
  value: true,
 | 
			
		||||
});
 | 
			
		||||
exports.NoDeprecatedCustomRule = NoDeprecatedCustomRule;
 | 
			
		||||
 | 
			
		||||
var _invariant = require('../../../jsutils/invariant.js');
 | 
			
		||||
 | 
			
		||||
var _GraphQLError = require('../../../error/GraphQLError.js');
 | 
			
		||||
 | 
			
		||||
var _definition = require('../../../type/definition.js');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * No deprecated
 | 
			
		||||
 *
 | 
			
		||||
 * A GraphQL document is only valid if all selected fields and all used enum values have not been
 | 
			
		||||
 * deprecated.
 | 
			
		||||
 *
 | 
			
		||||
 * Note: This rule is optional and is not part of the Validation section of the GraphQL
 | 
			
		||||
 * Specification. The main purpose of this rule is detection of deprecated usages and not
 | 
			
		||||
 * necessarily to forbid their use when querying a service.
 | 
			
		||||
 */
 | 
			
		||||
function NoDeprecatedCustomRule(context) {
 | 
			
		||||
  return {
 | 
			
		||||
    Field(node) {
 | 
			
		||||
      const fieldDef = context.getFieldDef();
 | 
			
		||||
      const deprecationReason =
 | 
			
		||||
        fieldDef === null || fieldDef === void 0
 | 
			
		||||
          ? void 0
 | 
			
		||||
          : fieldDef.deprecationReason;
 | 
			
		||||
 | 
			
		||||
      if (fieldDef && deprecationReason != null) {
 | 
			
		||||
        const parentType = context.getParentType();
 | 
			
		||||
        parentType != null || (0, _invariant.invariant)(false);
 | 
			
		||||
        context.reportError(
 | 
			
		||||
          new _GraphQLError.GraphQLError(
 | 
			
		||||
            `The field ${parentType.name}.${fieldDef.name} is deprecated. ${deprecationReason}`,
 | 
			
		||||
            {
 | 
			
		||||
              nodes: node,
 | 
			
		||||
            },
 | 
			
		||||
          ),
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    Argument(node) {
 | 
			
		||||
      const argDef = context.getArgument();
 | 
			
		||||
      const deprecationReason =
 | 
			
		||||
        argDef === null || argDef === void 0
 | 
			
		||||
          ? void 0
 | 
			
		||||
          : argDef.deprecationReason;
 | 
			
		||||
 | 
			
		||||
      if (argDef && deprecationReason != null) {
 | 
			
		||||
        const directiveDef = context.getDirective();
 | 
			
		||||
 | 
			
		||||
        if (directiveDef != null) {
 | 
			
		||||
          context.reportError(
 | 
			
		||||
            new _GraphQLError.GraphQLError(
 | 
			
		||||
              `Directive "@${directiveDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`,
 | 
			
		||||
              {
 | 
			
		||||
                nodes: node,
 | 
			
		||||
              },
 | 
			
		||||
            ),
 | 
			
		||||
          );
 | 
			
		||||
        } else {
 | 
			
		||||
          const parentType = context.getParentType();
 | 
			
		||||
          const fieldDef = context.getFieldDef();
 | 
			
		||||
          (parentType != null && fieldDef != null) ||
 | 
			
		||||
            (0, _invariant.invariant)(false);
 | 
			
		||||
          context.reportError(
 | 
			
		||||
            new _GraphQLError.GraphQLError(
 | 
			
		||||
              `Field "${parentType.name}.${fieldDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`,
 | 
			
		||||
              {
 | 
			
		||||
                nodes: node,
 | 
			
		||||
              },
 | 
			
		||||
            ),
 | 
			
		||||
          );
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    ObjectField(node) {
 | 
			
		||||
      const inputObjectDef = (0, _definition.getNamedType)(
 | 
			
		||||
        context.getParentInputType(),
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      if ((0, _definition.isInputObjectType)(inputObjectDef)) {
 | 
			
		||||
        const inputFieldDef = inputObjectDef.getFields()[node.name.value];
 | 
			
		||||
        const deprecationReason =
 | 
			
		||||
          inputFieldDef === null || inputFieldDef === void 0
 | 
			
		||||
            ? void 0
 | 
			
		||||
            : inputFieldDef.deprecationReason;
 | 
			
		||||
 | 
			
		||||
        if (deprecationReason != null) {
 | 
			
		||||
          context.reportError(
 | 
			
		||||
            new _GraphQLError.GraphQLError(
 | 
			
		||||
              `The input field ${inputObjectDef.name}.${inputFieldDef.name} is deprecated. ${deprecationReason}`,
 | 
			
		||||
              {
 | 
			
		||||
                nodes: node,
 | 
			
		||||
              },
 | 
			
		||||
            ),
 | 
			
		||||
          );
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    EnumValue(node) {
 | 
			
		||||
      const enumValueDef = context.getEnumValue();
 | 
			
		||||
      const deprecationReason =
 | 
			
		||||
        enumValueDef === null || enumValueDef === void 0
 | 
			
		||||
          ? void 0
 | 
			
		||||
          : enumValueDef.deprecationReason;
 | 
			
		||||
 | 
			
		||||
      if (enumValueDef && deprecationReason != null) {
 | 
			
		||||
        const enumTypeDef = (0, _definition.getNamedType)(
 | 
			
		||||
          context.getInputType(),
 | 
			
		||||
        );
 | 
			
		||||
        enumTypeDef != null || (0, _invariant.invariant)(false);
 | 
			
		||||
        context.reportError(
 | 
			
		||||
          new _GraphQLError.GraphQLError(
 | 
			
		||||
            `The enum value "${enumTypeDef.name}.${enumValueDef.name}" is deprecated. ${deprecationReason}`,
 | 
			
		||||
            {
 | 
			
		||||
              nodes: node,
 | 
			
		||||
            },
 | 
			
		||||
          ),
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										117
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoDeprecatedCustomRule.mjs
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										117
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoDeprecatedCustomRule.mjs
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,117 @@
 | 
			
		||||
import { invariant } from '../../../jsutils/invariant.mjs';
 | 
			
		||||
import { GraphQLError } from '../../../error/GraphQLError.mjs';
 | 
			
		||||
import { getNamedType, isInputObjectType } from '../../../type/definition.mjs';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * No deprecated
 | 
			
		||||
 *
 | 
			
		||||
 * A GraphQL document is only valid if all selected fields and all used enum values have not been
 | 
			
		||||
 * deprecated.
 | 
			
		||||
 *
 | 
			
		||||
 * Note: This rule is optional and is not part of the Validation section of the GraphQL
 | 
			
		||||
 * Specification. The main purpose of this rule is detection of deprecated usages and not
 | 
			
		||||
 * necessarily to forbid their use when querying a service.
 | 
			
		||||
 */
 | 
			
		||||
export function NoDeprecatedCustomRule(context) {
 | 
			
		||||
  return {
 | 
			
		||||
    Field(node) {
 | 
			
		||||
      const fieldDef = context.getFieldDef();
 | 
			
		||||
      const deprecationReason =
 | 
			
		||||
        fieldDef === null || fieldDef === void 0
 | 
			
		||||
          ? void 0
 | 
			
		||||
          : fieldDef.deprecationReason;
 | 
			
		||||
 | 
			
		||||
      if (fieldDef && deprecationReason != null) {
 | 
			
		||||
        const parentType = context.getParentType();
 | 
			
		||||
        parentType != null || invariant(false);
 | 
			
		||||
        context.reportError(
 | 
			
		||||
          new GraphQLError(
 | 
			
		||||
            `The field ${parentType.name}.${fieldDef.name} is deprecated. ${deprecationReason}`,
 | 
			
		||||
            {
 | 
			
		||||
              nodes: node,
 | 
			
		||||
            },
 | 
			
		||||
          ),
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    Argument(node) {
 | 
			
		||||
      const argDef = context.getArgument();
 | 
			
		||||
      const deprecationReason =
 | 
			
		||||
        argDef === null || argDef === void 0
 | 
			
		||||
          ? void 0
 | 
			
		||||
          : argDef.deprecationReason;
 | 
			
		||||
 | 
			
		||||
      if (argDef && deprecationReason != null) {
 | 
			
		||||
        const directiveDef = context.getDirective();
 | 
			
		||||
 | 
			
		||||
        if (directiveDef != null) {
 | 
			
		||||
          context.reportError(
 | 
			
		||||
            new GraphQLError(
 | 
			
		||||
              `Directive "@${directiveDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`,
 | 
			
		||||
              {
 | 
			
		||||
                nodes: node,
 | 
			
		||||
              },
 | 
			
		||||
            ),
 | 
			
		||||
          );
 | 
			
		||||
        } else {
 | 
			
		||||
          const parentType = context.getParentType();
 | 
			
		||||
          const fieldDef = context.getFieldDef();
 | 
			
		||||
          (parentType != null && fieldDef != null) || invariant(false);
 | 
			
		||||
          context.reportError(
 | 
			
		||||
            new GraphQLError(
 | 
			
		||||
              `Field "${parentType.name}.${fieldDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`,
 | 
			
		||||
              {
 | 
			
		||||
                nodes: node,
 | 
			
		||||
              },
 | 
			
		||||
            ),
 | 
			
		||||
          );
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    ObjectField(node) {
 | 
			
		||||
      const inputObjectDef = getNamedType(context.getParentInputType());
 | 
			
		||||
 | 
			
		||||
      if (isInputObjectType(inputObjectDef)) {
 | 
			
		||||
        const inputFieldDef = inputObjectDef.getFields()[node.name.value];
 | 
			
		||||
        const deprecationReason =
 | 
			
		||||
          inputFieldDef === null || inputFieldDef === void 0
 | 
			
		||||
            ? void 0
 | 
			
		||||
            : inputFieldDef.deprecationReason;
 | 
			
		||||
 | 
			
		||||
        if (deprecationReason != null) {
 | 
			
		||||
          context.reportError(
 | 
			
		||||
            new GraphQLError(
 | 
			
		||||
              `The input field ${inputObjectDef.name}.${inputFieldDef.name} is deprecated. ${deprecationReason}`,
 | 
			
		||||
              {
 | 
			
		||||
                nodes: node,
 | 
			
		||||
              },
 | 
			
		||||
            ),
 | 
			
		||||
          );
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    EnumValue(node) {
 | 
			
		||||
      const enumValueDef = context.getEnumValue();
 | 
			
		||||
      const deprecationReason =
 | 
			
		||||
        enumValueDef === null || enumValueDef === void 0
 | 
			
		||||
          ? void 0
 | 
			
		||||
          : enumValueDef.deprecationReason;
 | 
			
		||||
 | 
			
		||||
      if (enumValueDef && deprecationReason != null) {
 | 
			
		||||
        const enumTypeDef = getNamedType(context.getInputType());
 | 
			
		||||
        enumTypeDef != null || invariant(false);
 | 
			
		||||
        context.reportError(
 | 
			
		||||
          new GraphQLError(
 | 
			
		||||
            `The enum value "${enumTypeDef.name}.${enumValueDef.name}" is deprecated. ${deprecationReason}`,
 | 
			
		||||
            {
 | 
			
		||||
              nodes: node,
 | 
			
		||||
            },
 | 
			
		||||
          ),
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										15
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
import type { ASTVisitor } from '../../../language/visitor';
 | 
			
		||||
import type { ValidationContext } from '../../ValidationContext';
 | 
			
		||||
/**
 | 
			
		||||
 * Prohibit introspection queries
 | 
			
		||||
 *
 | 
			
		||||
 * A GraphQL document is only valid if all fields selected are not fields that
 | 
			
		||||
 * return an introspection type.
 | 
			
		||||
 *
 | 
			
		||||
 * Note: This rule is optional and is not part of the Validation section of the
 | 
			
		||||
 * GraphQL Specification. This rule effectively disables introspection, which
 | 
			
		||||
 * does not reflect best practices and should only be done if absolutely necessary.
 | 
			
		||||
 */
 | 
			
		||||
export declare function NoSchemaIntrospectionCustomRule(
 | 
			
		||||
  context: ValidationContext,
 | 
			
		||||
): ASTVisitor;
 | 
			
		||||
							
								
								
									
										41
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoSchemaIntrospectionCustomRule.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoSchemaIntrospectionCustomRule.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
'use strict';
 | 
			
		||||
 | 
			
		||||
Object.defineProperty(exports, '__esModule', {
 | 
			
		||||
  value: true,
 | 
			
		||||
});
 | 
			
		||||
exports.NoSchemaIntrospectionCustomRule = NoSchemaIntrospectionCustomRule;
 | 
			
		||||
 | 
			
		||||
var _GraphQLError = require('../../../error/GraphQLError.js');
 | 
			
		||||
 | 
			
		||||
var _definition = require('../../../type/definition.js');
 | 
			
		||||
 | 
			
		||||
var _introspection = require('../../../type/introspection.js');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Prohibit introspection queries
 | 
			
		||||
 *
 | 
			
		||||
 * A GraphQL document is only valid if all fields selected are not fields that
 | 
			
		||||
 * return an introspection type.
 | 
			
		||||
 *
 | 
			
		||||
 * Note: This rule is optional and is not part of the Validation section of the
 | 
			
		||||
 * GraphQL Specification. This rule effectively disables introspection, which
 | 
			
		||||
 * does not reflect best practices and should only be done if absolutely necessary.
 | 
			
		||||
 */
 | 
			
		||||
function NoSchemaIntrospectionCustomRule(context) {
 | 
			
		||||
  return {
 | 
			
		||||
    Field(node) {
 | 
			
		||||
      const type = (0, _definition.getNamedType)(context.getType());
 | 
			
		||||
 | 
			
		||||
      if (type && (0, _introspection.isIntrospectionType)(type)) {
 | 
			
		||||
        context.reportError(
 | 
			
		||||
          new _GraphQLError.GraphQLError(
 | 
			
		||||
            `GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`,
 | 
			
		||||
            {
 | 
			
		||||
              nodes: node,
 | 
			
		||||
            },
 | 
			
		||||
          ),
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										32
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								graphql-subscription/node_modules/graphql/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
import { GraphQLError } from '../../../error/GraphQLError.mjs';
 | 
			
		||||
import { getNamedType } from '../../../type/definition.mjs';
 | 
			
		||||
import { isIntrospectionType } from '../../../type/introspection.mjs';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Prohibit introspection queries
 | 
			
		||||
 *
 | 
			
		||||
 * A GraphQL document is only valid if all fields selected are not fields that
 | 
			
		||||
 * return an introspection type.
 | 
			
		||||
 *
 | 
			
		||||
 * Note: This rule is optional and is not part of the Validation section of the
 | 
			
		||||
 * GraphQL Specification. This rule effectively disables introspection, which
 | 
			
		||||
 * does not reflect best practices and should only be done if absolutely necessary.
 | 
			
		||||
 */
 | 
			
		||||
export function NoSchemaIntrospectionCustomRule(context) {
 | 
			
		||||
  return {
 | 
			
		||||
    Field(node) {
 | 
			
		||||
      const type = getNamedType(context.getType());
 | 
			
		||||
 | 
			
		||||
      if (type && isIntrospectionType(type)) {
 | 
			
		||||
        context.reportError(
 | 
			
		||||
          new GraphQLError(
 | 
			
		||||
            `GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`,
 | 
			
		||||
            {
 | 
			
		||||
              nodes: node,
 | 
			
		||||
            },
 | 
			
		||||
          ),
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user