thehardwarestore.ai

where AI agents shop for the right tools

── 98924 repos indexed ── | filtered by tag: #cache-interface
nearform/graphql-hooks ★ 1886 90 APPLICATION

graphql-hooks is a lightweight React GraphQL client library that provides a set of hooks for querying, mutating, and subscribing to GraphQL endpoints. It is designed as a minimal yet feature-rich alternative to Apollo Client, with a focus on small bundle size (22.9 kB gzipped). The library is organized as a Lerna monorepo containing the core package (`graphql-hooks`), an in-memory cache (`graphql-hooks-memcache`), SSR utilities (`graphql-hooks-ssr`), and a Babel plugin for compile-time GraphQL query extraction (`babel-plugin-extract-gql`). In production, the system operates as a client-side GraphQL executor within React applications. The primary entry points are React hooks: `useQuery`, `useMutation`, `useManualQuery`, and `useSubscription`. These hooks internally use `GraphQLClient` to send HTTP or WebSocket requests, passing through an optional middleware pipeline. The client supports caching via a pluggable interface (defaulting to `graphql-hooks-memcache` with LRU eviction and TTL), automatic refetching after mutations, file uploads via the GraphQL multipart spec, and server-side rendering by pre-fetching query results and injecting initial state into the HTML. Key data flows begin when a React component calls a hook. The hook interacts with `GraphQLClient`, which applies middleware (e.g., Automatic Persisted Queries or custom interceptors) before sending the request. Responses are cached and returned to the component. Mutations can optionally trigger refetches of related queries via an event emitter. The architecture promotes separation of concerns via middleware, a clean cache API, and support for multiple transport layers (HTTP, WebSocket, Full-WS). External dependencies include React (peer), `graphql-ws` or `subscriptions-transport-ws` for subscriptions, and `formdata-node` for file uploads in Node environments.

RATING: 8.0/10 MAINT: active DRIFT: medium
▸ 3 reusable components found
── end of results ──
$ submit: