OrJDev / create-jd-app

The quickest and most efficient way to start new full stack, type safed Solid web app
671 stars 26 forks source link

trpc query options works not as expected 🧐 #100

Closed armandsalle closed 1 year ago

armandsalle commented 1 year ago

Hey! First of all, thank you for your template 🙌

I think this is more related to the tRPC + Tanstack Query adapter for solid, but in your doc for solid-trpc here it shows how to use the enabled property with a get method. I tried it but I got a TS error and a runtime error.

So from this that doesn't work

 const secret = trpc.example.secret.useQuery(undefined, {
    get enabled() {
      return !!session()
    },
  })

I did that, and it's working great

  const secret = trpc.example.secret.useQuery(undefined, () => ({
    enabled: !!session(),
  }))

The only issue I found is that refetchOnWindowFocus: true, doesn't work... I didn't found anything about why, maybe you know? Or maybe this stack is not bullet proof or so for side projects? 🤷‍♂️

Thank's in advance 🙌

armandsalle commented 1 year ago

Sorry I just understand my mistake...

createEffect(() => {
    console.log(secret.data)
})

Yes, this isn't react so my log was printed once even if it refetches because the data never changed 🤣

I'm so sorry about the PR