⬡ GraphQL Intermediate

What is urql and how does it compare to Apollo Client?

Answer

urql (Universal React Query Library) is a lightweight, extensible GraphQL client for React, Svelte, Vue, and vanilla JS. Comparison with Apollo Client: Size: urql is ~5KB vs Apollo Client's ~30KB+ — significant for bundle-size-sensitive apps. Caching: urql uses document-based caching by default (cache entire query results) vs Apollo's normalized cache. urql also has an optional Graphcache plugin for normalized caching. Simplicity: urql has a simpler API and less configuration needed. Flexibility: urql uses an "exchanges" pipeline (middleware system) that is highly composable — auth, retry, offline, subscriptions are all exchanges. Ecosystem: Apollo Client has a larger ecosystem, better Apollo Studio integration, and more community resources. When to choose urql: bundle size matters, simpler caching requirements, or preference for a more modular architecture.