GQless 2.0 builds upon the ideas from gqless 1.0, adding support for mutations, subscriptions and new hooks for React, to make lazy loading, suspense, and other patterns much easier.
Here's a breakdown of what's changed:
Support for mutations has been added. They work very similarly to queries, using the
mutation object instead.
Support for subscriptions is now here. You can build realtime user interfaces with GQless now.
useQuery hook has been added, which you can use in replacement of the HoC
The new hooks include:
useTransactionQuery: Giving you access to loading state, polling, and more.
useLazyQuery: A query that can be triggered conditionally.
useRefetch: A hook that works alongside regular useQuery, letting your programatically make it refetch.
useMutation: More control over mutations with loading states.
useSubscription: Likewise, a hook for subscriptions.
useMetaState: Lets you hook into the fetch state of gqless and output errors.
useHydrateCache: For restoring SSR state to the client.
And the new helpers functions:
prepareQuery: Extract queries above components, letting you do fancier early-fetching on important queries.
prepareReactRender: Use before rendering React to trigger getting data.
Server-Side rendering (SSR) is now supported, which works great with Next.js. See React SSR for more
Theres new support for caching strategies and persistence, that allow your queries to retrieve previously fetched data. It supports the
as well as
no-cache policies, and lets you configure how you want your cache to persist for cross-session persistence.
Normalized caching has also been improved.
File uploading is now supported, see here for more.
Runtime speed has been dramatically increased, fetching data now scales much better - the largest queries will see the greatest benefit. The schema format has been simplified. Types are now also generated differently. You should see significant gains in TypeScript compiler performance.
If this sounds exciting, head over to the Getting started page