blitz-js / blitz

⚡️ The Missing Fullstack Toolkit for Next.js
https://Blitzjs.com
MIT License
13.68k stars 798 forks source link

useQuery still calls via https when not enabled #4099

Closed Vandivier closed 1 year ago

Vandivier commented 1 year ago

What is the problem?

i have a UI component that needs data sets A or B. the client should exclusively request one at a time and should never make https calls for both. unfortunately, it seems like useQuery is making both http calls every time, even though enabled is set to false for one.

the component ends up getting the right data, but on my chrome devtools i see both calls are being made

Paste all your error logs here:

PASTE_HERE (leave the ``` marks)

Paste all relevant code snippets here:

  import { useQuery } from "@blitzjs/rpc"
...
  const [donations] = useQuery(getLatestWeekDonations, {
    enabled: true,
  })
  const [pledges] = useQuery(getLatestWeekPledges, {
    enabled: false,
  })

What are detailed steps to reproduce this?

1.

Run blitz -v and paste the output here:


$ blitz -v
Blitz version: 2.0.0-beta.19 (global)
Blitz version: 2.0.0-beta.19 (local)
Windows 11 | win32-x64 | Node: v19.3.0

 Package manager: npm

  System:
    OS: Windows 10 10.0.22621
    CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
    Memory: 1.02 GB / 7.88 GB
  Binaries:
    Node: 19.3.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.8.0 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    @blitzjs/auth: 2.0.0-beta.19 => 2.0.0-beta.19
    @blitzjs/next: 2.0.0-beta.19 => 2.0.0-beta.19
    @blitzjs/rpc: 2.0.0-beta.19 => 2.0.0-beta.19
    @prisma/client: 4.6.0 => 4.6.0
    blitz: 2.0.0-beta.19 => 2.0.0-beta.19
    next: 12.2.5 => 12.2.5
    prisma: 4.6.0 => 4.6.0
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    typescript: ^4.8.4 => 4.9.4

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

No response

siddhsuresh commented 1 year ago

Hey @Vandivier, could you provide a minimal reproduction for this?

Vandivier commented 1 year ago

closing bc the project i was on where this occurred it closed source but i'm no longer getting paid to work on it, so i have very little motivation to extract the repro from it any time soon