import { GraphQLOperation, CacheEntry, GraphQLSchema } from '../../shared/types'; import { GraphQLClientAdapter, AdapterConfig } from './types'; import { ApolloClient as ApolloClientType, ApolloLink, Observable, FetchResult, Operation } from '@apollo/client'; type ApolloClient = ApolloClientType; /** * Apollo Client adapter for the GraphQL DevTools plugin. * * This adapter integrates with Apollo Client using Apollo Link middleware * to intercept all GraphQL operations with full request/response lifecycle tracking. * * IMPORTANT: Add the Rozenite link as the FIRST link in your Apollo Client chain: * ```typescript * import { ApolloClient, InMemoryCache, ApolloLink, HttpLink } from '@apollo/client'; * import { apolloGraphqlDevtoolLink } from 'rozenite-graphql-client-devtool'; * * const client = new ApolloClient({ * link: ApolloLink.from([ * apolloGraphqlDevtoolLink(), // Must be first to capture all operations * new HttpLink({ uri: 'https://api.example.com/graphql' }), * ]), * cache: new InMemoryCache(), * }); * * // Then initialize the adapter * const adapter = new ApolloClientAdapter(client); * adapter.initialize(); * ``` */ export declare class ApolloClientAdapter implements GraphQLClientAdapter { private client; private config; private operationCallbacks; private cacheCallbacks; private operationCounter; constructor(client: ApolloClient, config?: AdapterConfig); initialize(): void; cleanup(): void; /** * Internal method to track an operation through the link */ trackOperation(operation: Operation, forward: any): Observable; getCacheSnapshot(): CacheEntry[]; getSchema(): Promise; onOperation(callback: (operation: GraphQLOperation) => void): () => void; onCacheChange(callback: (entry: CacheEntry) => void): () => void; /** * Helper method to notify all operation callbacks */ private notifyOperationCallbacks; } /** * Helper function to create a Rozenite DevTools Link for Apollo Client. * * This link intercepts all GraphQL operations (queries, mutations, subscriptions) * and captures their complete lifecycle including request/response data. * * **IMPORTANT**: Add this as the FIRST link in your Apollo Client chain to ensure * all operations are captured, including duplicates that may be deduplicated later. * * @example * ```typescript * import { ApolloClient, InMemoryCache, ApolloLink, HttpLink } from '@apollo/client'; * import { apolloGraphqlDevtoolLink, useGraphqlClientDevtool } from 'rozenite-graphql-client-devtool'; * * // 1. Create the link * const rozeniteLink = apolloGraphqlDevtoolLink(); * * // 2. Add as FIRST link in the chain * const client = new ApolloClient({ * link: ApolloLink.from([ * rozeniteLink, // Must be first to capture ALL operations * new HttpLink({ uri: 'https://api.example.com/graphql' }), * ]), * cache: new InMemoryCache(), * }); * * // 3. Initialize the devtool in your component * function App() { * useGraphqlClientDevtool({ * client, * clientType: 'apollo', * }); * * return ; * } * ``` * * @returns ApolloLink instance configured for Rozenite DevTools */ export declare function apolloGraphqlDevtoolLink(): ApolloLink; export {};