schemaVisitor.d.ts 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { GraphQLArgument, GraphQLDirective, GraphQLEnumType, GraphQLEnumValue, GraphQLField, GraphQLInputField, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLUnionType } from 'graphql';
  2. export declare type VisitableSchemaType = GraphQLSchema | GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType | GraphQLNamedType | GraphQLScalarType | GraphQLField<any, any> | GraphQLArgument | GraphQLUnionType | GraphQLEnumType | GraphQLEnumValue | GraphQLInputField;
  3. export declare abstract class SchemaVisitor {
  4. schema: GraphQLSchema;
  5. static implementsVisitorMethod(methodName: string): boolean;
  6. visitSchema(schema: GraphQLSchema): void;
  7. visitScalar(scalar: GraphQLScalarType): GraphQLScalarType | void | null;
  8. visitObject(object: GraphQLObjectType): GraphQLObjectType | void | null;
  9. visitFieldDefinition(field: GraphQLField<any, any>, details: {
  10. objectType: GraphQLObjectType | GraphQLInterfaceType;
  11. }): GraphQLField<any, any> | void | null;
  12. visitArgumentDefinition(argument: GraphQLArgument, details: {
  13. field: GraphQLField<any, any>;
  14. objectType: GraphQLObjectType | GraphQLInterfaceType;
  15. }): GraphQLArgument | void | null;
  16. visitInterface(iface: GraphQLInterfaceType): GraphQLInterfaceType | void | null;
  17. visitUnion(union: GraphQLUnionType): GraphQLUnionType | void | null;
  18. visitEnum(type: GraphQLEnumType): GraphQLEnumType | void | null;
  19. visitEnumValue(value: GraphQLEnumValue, details: {
  20. enumType: GraphQLEnumType;
  21. }): GraphQLEnumValue | void | null;
  22. visitInputObject(object: GraphQLInputObjectType): GraphQLInputObjectType | void | null;
  23. visitInputFieldDefinition(field: GraphQLInputField, details: {
  24. objectType: GraphQLInputObjectType;
  25. }): GraphQLInputField | void | null;
  26. }
  27. export declare function visitSchema(schema: GraphQLSchema, visitorSelector: (type: VisitableSchemaType, methodName: string) => SchemaVisitor[]): GraphQLSchema;
  28. export declare function healSchema(schema: GraphQLSchema): GraphQLSchema;
  29. export declare class SchemaDirectiveVisitor extends SchemaVisitor {
  30. name: string;
  31. args: {
  32. [name: string]: any;
  33. };
  34. visitedType: VisitableSchemaType;
  35. context: {
  36. [key: string]: any;
  37. };
  38. static getDirectiveDeclaration(directiveName: string, schema: GraphQLSchema): GraphQLDirective;
  39. static visitSchemaDirectives(schema: GraphQLSchema, directiveVisitors: {
  40. [directiveName: string]: typeof SchemaDirectiveVisitor;
  41. }, context?: {
  42. [key: string]: any;
  43. }): {
  44. [directiveName: string]: SchemaDirectiveVisitor[];
  45. };
  46. protected static getDeclaredDirectives(schema: GraphQLSchema, directiveVisitors: {
  47. [directiveName: string]: typeof SchemaDirectiveVisitor;
  48. }): {
  49. [directiveName: string]: GraphQLDirective;
  50. };
  51. protected constructor(config: {
  52. name: string;
  53. args: {
  54. [name: string]: any;
  55. };
  56. visitedType: VisitableSchemaType;
  57. schema: GraphQLSchema;
  58. context: {
  59. [key: string]: any;
  60. };
  61. });
  62. }