effector / effector/farfetched

[API Design](Cache): Should ignore passed params into query for generating cache key if not expected by query

Open
#349 2 comments 0 reactions 0 assignees View on GitHub
discussion scope:core
Dominant language
TypeScript
Stars
221
Forks
36
PR merge metrics
No merged PRs in 30d

Description

Precondition: [docs](https://farfetched.pages.dev/recipes/cache.html#hashing-algorithm)
```
So, the key is a hash of the following data:
- SID of the Query
- params of the particular call of the Query
- current values of all external Stores that affect Query
To get short and unique key, we stringify all data, concatenate it and then hash it with SHA-1.
```

This design desigion does not take into account pattern within effector community with sample:
If EventPayload of target is void, user can pass data in any shape without any warning, thus it can be unintuitive, why they hit cache miss on, for example, page route params refetch

```
const getDataQuery = createQuery({
effect: () => Promise.resolve([])
})

sample({
clock: pageOpened // Event<{ params: { id: '1' }, query: {} }>
target: getDataQuery.start
})

sample({
clock: pageUpdated // Event<{ params: { id: '2'}, query: {} }>
target: getDataQuery.start
})

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.