Skip to main content

What's new in 2.0

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:

Mutations#

Support for mutations has been added. They work very similarly to queries, using the mutation object instead.

Subscriptions#

Support for subscriptions is now here. You can build realtime user interfaces with GQless now.

React Hooks#

The 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#

Server-Side rendering (SSR) is now supported, which works great with Next.js. See React SSR for more

Caching strategies and fetch policies#

Theres new support for caching strategies and persistence, that allow your queries to retrieve previously fetched data. It supports the stale-while-revalidate pattern as well as cache-and-network, cache-first, network-only and 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#

File uploading is now supported, see here for more.

Improved performance#

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.

Client configuration#

You can now configure options for the core-client and react integration. A retry option allows for failed queries to retry automatically.

Getting started#

If this sounds exciting, head over to the Getting started page

Last updated on by Sam Denty