import type { GraphQLScalarType, GraphQLFieldResolver as BaseGraphQLFieldResolver, GraphQLSchema } from "graphql"; import type { Plugin } from "@webiny/plugins/types.js"; import type { Context, GenericRecord } from "@webiny/api/types.js"; import type { RouteMethodPath } from "@webiny/handler/types.js"; import type { ResolversComposition } from "@graphql-tools/resolvers-composition"; import type { IResolvers, TypeSource } from "@graphql-tools/utils"; export interface GraphQLScalarPlugin extends Plugin { type: "graphql-scalar"; scalar: GraphQLScalarType; } export interface HandlerGraphQLOptions { path?: RouteMethodPath; debug?: boolean | string; } export type GraphQLFieldResolver = BaseGraphQLFieldResolver; /** * @deprecated Use `TypeDefs` instead. */ export type Types = TypeDefs; export type TypeDefs = TypeSource; export interface GraphQLSchemaPluginTypeArgs { context?: any; args?: any; source?: any; } export type Resolvers = IResolvers; export type ResolverDecorator = ResolversComposition>; export type ResolverDecorators = GenericRecord; export interface GraphQLSchemaDefinition { typeDefs: TypeDefs; resolvers?: Resolvers; resolverDecorators?: ResolverDecorators; } export interface GraphQLSchemaPlugin extends Plugin { type: "graphql-schema"; schema: GraphQLSchemaDefinition; } export interface GraphQLRequestBody { query: string; variables?: Record | null; operationName?: string; } export interface GraphQLBeforeQueryPlugin extends Plugin { type: "graphql-before-query"; apply(params: { body: GraphQLRequestBody; schema: GraphQLSchema; context: TContext; }): void; } export interface GraphQLAfterQueryPlugin extends Plugin { type: "graphql-after-query"; apply(params: { result: any; body: GraphQLRequestBody; schema: GraphQLSchema; context: TContext; }): void; }