Skip to content
On this page

v0.6 Huai Nam Dang

Huai Nam Dang

Photo by Maria Goroshko

Why Huai Nam Dang?

Huai Nam Dang is a national park in the North of Thailand. It is one of the coldest places in Thailand (like 12 °C or 53 °F) 🥶

It's pretty compact release with only one notable change - attachOperation which allows coping of Query or Mutation with altering parameters.

ts
import { createStore } from 'effector';
import { attachOperation, createQuery } from '@farfetched/core';

const $externalStore = createStore(12);

const originalQuery = createQuery({
  handler: async (params: string) => 'some data',
});

const attachedQuery = attachOperation(originalQuery, {
  source: $externalStore,
  mapParams: (params: number, externalSource) => (params + externalSource).toString(),
});

It also includes a couple of minor improvements and bug fixes. Read the full changelog below.

Migration guide

Since v0.5, Farfetched supports @@unitShape protocol, so you can use useUnit from effector-react and effector-solid to subscribe to custom entities like Query and Mutation.

Do not use @farfetched/react

Package @farfetched/react is deprecated, just use useUnit from effector-react instead of useQuery and useMutation 🪄

tsx
import { useQuery, useMutation } from '@farfetched/react'; 
import { useUnit } from 'effector-react'; 

function User() {
  const { data: user } = useQuery(userQuery); 
  const { data: user } = useUnit(userQuery); 

  const { start: deleteAccount } = useMutation(deleteAccountMutation); 
  const { start: deleteAccount } = useUnit(deleteAccountMutation); 

  return (
    <div>
      <p>Name: {user.name}</p>
      <button onClick={deleteAccount}>Delete my account</button>
    </div>
  );
}

Do not use useMutation from @farfetched/solid

Function useMutation from @farfetched/solid is deprecated, just use useUnit from effector-solid instead 🪄

tsx
import {
  createQueryResource,
  useMutation, 
} from '@farfetched/solid';
import { useUnit } from 'effector-react'; 

function User() {
  const [user] = createQueryResource(userQuery);

  const { start: deleteAccount } = useMutation(deleteAccountMutation); 
  const { start: deleteAccount } = useUnit(deleteAccountMutation); 

  return (
    <Suspense fallback={<p>Loading...</p>}>
      <div>
        <p>Name: {user().name}</p>
        <button onClick={deleteAccount}>Delete my account</button>
      </div>
    </Suspense>
  );
}

TIP

Q: Why createQueryResource is still there?

A: Because @@unitShape protocol supports only shapes of units, not custom operations like binding Query with Suspense of Solid.

Full changelog

0.6.4

@farfetched/core

Patch Changes

  • 5da04bf: Fix type inference in createQuery in effect and mapData overload

0.6.3

@farfetched/solid

Patch Changes

  • 0a45391: Re-trigger resource after update a Query

0.6.2

@farfetched/core

Patch Changes

  • 05b4860: Fix cache invalidation after update

0.6.1

@farfetched/core

Patch Changes

  • c2b67a6: Fix cache overlapping in createJsonQuery

0.6.0

@farfetched/core

Minor Changes

  • 521834d: Allow passing abort signal to createJsonQuery and createJsonMutation
  • f7def6f: Ignore params while cache createJsonQuery to decrease number of cache misses
  • b57c5ee: Add attachOperation operator
  • c2431af: Parse response in httpError in createJson* as JSON
  • b57c5ee: Expose initialData in Query meta

Patch Changes

  • fa4a40f: Return null for empty response in createJsonApiRequest instead of preparationError
@farfetched/solid

Minor Changes

  • dc6ee4c: Delete deprecated useMutation in favour of @@unitShape protocol

Released under the MIT License.