blitz-js / blitz-js/blitz

Does the invoke query function make use of the query cache?

Open
#4,417 0 comments 0 reactions 0 assignees View on GitHub
kind/bug status/triage
Dominant language
TypeScript
Stars
14.1k
Forks
803
PR merge metrics
No merged PRs in 30d

Description

### What is the problem?

it does not seem to work. Also the queryKey is not what i would expect if you look at what getQueryKey returns.
example:

```ts
const getData = await () => {
const data = await invoke(getDataQuery, { filters })
}
```

calling the function a second time does fire a new network request although the i can see the cache data in the ReactQueryDevTools. Also setting the cache manually does not seem to work, because the queryKey does not align. for example getQueryKey(getDataQuery) return /api/rpc/getDataQuery while the ReactQueryDevTools shows that the cache is under: /getDataQuery

### Paste all your error logs here:

```
no error
```

### Paste all relevant code snippets here:

```
const getData = await () => {
const data = await invoke(getDataQuery, { filters })
}
```
calling it a second time does not look at the cache first, but fires a new network request every time

### What are detailed steps to reproduce this?

1. use invoke multiple times

### Run `blitz -v` and paste the output here:

```
Blitz version: 2.2.1 (local)
macOS | darwin-arm64 | Node: v22.11.0

Package manager: yarn

System:
OS: macOS 15.1.1
CPU: (16) arm64 Apple M4 Max
Memory: 13.51 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.11.0 - /var/folders/kl/_y4btmss0bs8rdjbt3myf0l80000gn/T/yarn--1738415884311-0.8913226632239895/node
Yarn: 1.22.22 - /var/folders/kl/_y4btmss0bs8rdjbt3myf0l80000gn/T/yarn--1738415884311-0.8913226632239895/yarn
npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm
npmPackages:
@blitzjs/auth: 2.2.1 => 2.2.1
@blitzjs/next: 2.2.1 => 2.2.1
@blitzjs/rpc: 2.2.1 => 2.2.1
@prisma/client: Not Found
blitz: 2.2.1 => 2.2.1
next: 14.1.4 => 14.1.4
prisma: Not Found
react: ^18.2.0 => 18.3.1
react-dom: ^18.2.0 => 18.3.1
typescript: ^5.5.3 => 5.5.3
```

### Please include below any other applicable logs and screenshots that show your problem:

na

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.