/** * useQueryParams Hook - GraphQL Integration for URL State Management * * Automatically generates URL state management from GraphQL queries. * Parses query AST at runtime, flattens nested input types, and syncs with URL. * * @example * const LOGS_QUERY = gql` * query GetLogs($search: String, $filter: LogFilterInput) { ... } * ` * * const { variables, setParam } = useQueryParams(LOGS_QUERY) * const { data } = useQuery(LOGS_QUERY, { variables }) * * // URL: /logs?search=error&severity=critical * // variables: { search: 'error', filter: { severity: ['critical'] } } */ import { DocumentNode } from 'graphql'; import { FlattenedParam } from './flatten-schema'; /** * Options for useQueryParams hook */ export interface UseQueryParamsOptions { /** Default values for parameters */ defaultValues?: Record; /** GraphQL endpoint for introspection (defaults to process.env.NEXT_PUBLIC_API_URL/graphql) */ introspectionEndpoint?: string; /** HTTP headers for introspection (e.g., authentication) */ introspectionHeaders?: Record; /** Skip introspection (use only AST parsing, no nested type flattening) */ skipIntrospection?: boolean; /** Custom parameter name mapping (override auto-generated names) */ paramMapping?: Record; /** Enable debug logging */ debug?: boolean; } /** * Return type for useQueryParams hook */ export interface UseQueryParamsReturn> { /** GraphQL variables ready for Apollo Client */ variables: TVariables; /** Raw URL parameters (before conversion to variables) */ params: Record; /** Flattened parameter schema */ schema: Record; /** Set a single parameter */ setParam: (key: string, value: any) => void; /** Set multiple parameters at once */ setParams: (params: Record) => void; /** Clear specific parameters */ clearParams: (keys: string[]) => void; /** Reset all parameters (clear URL) */ resetParams: () => void; /** Whether schema is ready (introspection complete) */ isReady: boolean; /** Loading state during initialization */ isLoading: boolean; /** Error during initialization */ error: Error | null; } /** * useQueryParams - Auto-generate URL state from GraphQL query * * This hook: * 1. Parses GraphQL query AST to extract variable definitions * 2. Fetches GraphQL schema via introspection (optional, cached) * 3. Flattens nested input types to simple URL parameters * 4. Syncs URL ↔ GraphQL variables bidirectionally * 5. Provides type-safe parameter updates * * @param query - GraphQL DocumentNode (from gql`` template tag) * @param options - Configuration options * @returns Hook API for managing URL state */ export declare function useQueryParams>(query: DocumentNode, options?: UseQueryParamsOptions): UseQueryParamsReturn; //# sourceMappingURL=use-query-params.d.ts.map