qmetrics.net

GraphQL Hooks

Minimal hooks-first GraphQL client for React applications

graphql-hooks is a small React GraphQL client built around hooks such as useQuery and useMutation. It wraps a provider and client with optional caching, SSR, and subscriptions support.

Overview

graphql-hooks is a GraphQL client aimed at React applications that prefer a hooks-based API over render-prop components. You create a GraphQLClient, wrap the app with a context provider, and call hooks in child components to fetch and mutate data.

The package emphasizes a concise API and a small bundle size compared with larger clients. Hooks cover queries, manual queries, mutations, and subscriptions, with straightforward loading and error state handling. Optional companion packages add server-side rendering and in-memory cache implementations.

The client talks to a GraphQL HTTP endpoint and can route subscriptions through WebSocket transports such as subscriptions-transport-ws or graphql-ws when configured. Configuration covers headers, middleware, GET for queries, persisted queries, cache control, and pagination patterns.

Documentation contrasts the library with Apollo’s hooks API, noting trade-offs around bundle size versus advanced cache configuration. Migrating from Apollo Client patterns is documented for client, provider, and component equivalents.

Key features

  • React hooks API for queries
  • useMutation and useSubscription
  • Optional memcache plugin
  • SSR support via companion package
  • Small client bundle
  • Manual query hook
  • HTTP GET query option
  • File upload support

Use cases

  • React apps needing a light GraphQL client
  • Teams avoiding render-prop GraphQL components
  • Server-side rendered React with GraphQL
  • GraphQL subscriptions in React
  • Migrating from Apollo hook patterns

Tags

Similar software

FastAPI

Python web framework for building APIs with type hints

FastAPI is a Python web framework for building APIs using standard type hints. It builds on Starlette and Pydantic and generates interactive OpenAPI documentation for the endpoints you define.

★ 105.1k⟳ 9 days agoMIT

NestJS

Progressive TypeScript framework for Node.js backends

Nest organizes Node server apps with modules, dependency injection, and first-party packages for auth, data, queues, and observability.

★ 77.2k⟳ todayMIT

OkHttp

HTTP client for JVM, Android, and GraalVM

OkHttp is an HTTP client library tuned for efficient networking on Android, Java, and GraalVM native images. It offers synchronous and asynchronous call APIs with a fluent request builder.

★ 47.1k⟳ yesterdayApache-2.0
Frameworks & PlatformsDesktop/CLI app

gRPC

Cross-language remote procedure call framework

gRPC is an RPC framework that lets client and server programs communicate transparently and supports building connected, multi-language systems.

★ 45.5k⟳ todayApache-2.0

tRPC

End-to-end typesafe TypeScript APIs without code generation

tRPC helps teams define server procedures and call them from clients with full TypeScript types for inputs, outputs, and errors—no schemas or codegen step.

★ 40.9k⟳ todayMIT
Frameworks & PlatformsDesktop/CLI app

go-zero

Cloud-native Go microservices and RPC framework

go-zero is a Go web and RPC framework with code generation, built-in resilience middleware, and tooling aimed at stable high-traffic services.

★ 33.5k⟳ 9 days agoMIT