Skip to main content

New in 2.0

GQless V2 adds support for mutations, subscriptions and new hooks for React to make lazy loading, suspense, and other patterns easier.

Runtime Performance#

V2 is dramatically faster at fetching, especially with large amounts of data. The schema format has too rewritten to avoid creating many intermediate objects. The larger your query result is, the better version 2 will perform compared to v1.

Typescript Performance#

V2 changes how types are generated, dramatically increasing performance. This flattens things quite a bit, and we've seen no performance issues, even on very large schemas .

Mutations#

V2 adds mutations support - they work similarly to queries, using the mutation object.

Subscriptions#

V2 adds subscriptions support.

Caching strategies and fetch policies#

V2 adds caching strategies and persistence, that allow your queries to automatically resolve 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.

Built in normalized caching works as well, which will recognize the same object across different types of queries.

Server-side Rendering#

v2 adds Server-Side rendering (SSR) first-class support.

Check React Server-Side Rendering

React Hooks#

V2 removes the need to only use a higher order component, and lets you just use a simple useQuery hook for React.

Alongside that, there are many new hooks that handle common use cases:

  • 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.

As well as some helpers:

  • prepareQuery: Extract queries above components, letting you do fancier early-fetching on important queries.
  • prepareReactRender: Use before rendering React to trigger getting data.

Revamped configuration#

V2 adds many new Core and React configuration options, with highlights including retry for retrying failed queries automatically.

Uploads#

V2 adds support for uploading files.

Last updated on by Sam Denty