import { DocumentNode } from 'graphql'; import { c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-DE19n76Q.js'; import { a as GraphQLQuery, b as GraphQLVariables, e as GraphQLHandlerNameSelector, G as GraphQLHandler, f as GraphQLResolverExtras, g as GraphQLResponseBody } from './GraphQLHandler-Cu4Xvg4S.js'; import { Path } from './utils/matching/matchRequestUrl.js'; import './utils/internal/isIterable.js'; import './typeUtils.js'; interface TypedDocumentNode extends DocumentNode { __apiType?: (variables: Variables) => Result; __resultType?: Result; __variablesType?: Variables; } type GraphQLRequestHandler = (operationName: GraphQLHandlerNameSelector | DocumentNode | TypedDocumentNode, resolver: GraphQLResponseResolver<[ Query ] extends [never] ? GraphQLQuery : Query, Variables>, options?: RequestHandlerOptions) => GraphQLHandler; type GraphQLResponseResolver = ResponseResolver, null, GraphQLResponseBody<[Query] extends [never] ? GraphQLQuery : Query>>; declare const standardGraphQLHandlers: { /** * Intercepts a GraphQL query by a given name. * * @example * graphql.query('GetUser', () => { * return HttpResponse.json({ data: { user: { name: 'John' } } }) * }) * * @see {@link https://mswjs.io/docs/api/graphql#graphqlqueryqueryname-resolver `graphql.query()` API reference} */ query: GraphQLRequestHandler; /** * Intercepts a GraphQL mutation by its name. * * @example * graphql.mutation('SavePost', () => { * return HttpResponse.json({ data: { post: { id: 'abc-123 } } }) * }) * * @see {@link https://mswjs.io/docs/api/graphql#graphqlmutationmutationname-resolver `graphql.query()` API reference} * */ mutation: GraphQLRequestHandler; /** * Intercepts any GraphQL operation, regardless of its type or name. * * @example * graphql.operation(() => { * return HttpResponse.json({ data: { name: 'John' } }) * }) * * @see {@link https://mswjs.io/docs/api/graphql#graphloperationresolver `graphql.operation()` API reference} */ operation: (resolver: ResponseResolver, null, GraphQLResponseBody>) => GraphQLHandler; }; declare function createGraphQLLink(url: Path): typeof standardGraphQLHandlers; /** * A namespace to intercept and mock GraphQL operations * * @example * graphql.query('GetUser', resolver) * graphql.mutation('DeletePost', resolver) * * @see {@link https://mswjs.io/docs/api/graphql `graphql` API reference} */ declare const graphql: { /** * Intercepts GraphQL operations scoped by the given URL. * * @example * const github = graphql.link('https://api.github.com/graphql') * github.query('GetRepo', resolver) * * @see {@link https://mswjs.io/docs/api/graphql#graphqllinkurl `graphql.link()` API reference} */ link: typeof createGraphQLLink; /** * Intercepts a GraphQL query by a given name. * * @example * graphql.query('GetUser', () => { * return HttpResponse.json({ data: { user: { name: 'John' } } }) * }) * * @see {@link https://mswjs.io/docs/api/graphql#graphqlqueryqueryname-resolver `graphql.query()` API reference} */ query: GraphQLRequestHandler; /** * Intercepts a GraphQL mutation by its name. * * @example * graphql.mutation('SavePost', () => { * return HttpResponse.json({ data: { post: { id: 'abc-123 } } }) * }) * * @see {@link https://mswjs.io/docs/api/graphql#graphqlmutationmutationname-resolver `graphql.query()` API reference} * */ mutation: GraphQLRequestHandler; /** * Intercepts any GraphQL operation, regardless of its type or name. * * @example * graphql.operation(() => { * return HttpResponse.json({ data: { name: 'John' } }) * }) * * @see {@link https://mswjs.io/docs/api/graphql#graphloperationresolver `graphql.operation()` API reference} */ operation: (resolver: ResponseResolver, null, GraphQLResponseBody>) => GraphQLHandler; }; export { type GraphQLRequestHandler, type GraphQLResponseResolver, type TypedDocumentNode, graphql };