Mutations, subscriptions and new hooks for React make lazy loading, suspense, and other patterns much easier. Here's a breakdown of what's changed:
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 generated differently. You should see significant gains in TypeScript compiler performance.
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.
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.
Server-Side rendering (SSR) is now supported, which works great with Next.js. See React SSR for more
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.
File uploading is now supported, see here for more.