-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onSuccess(data) not typed correctly #509
Comments
I just add a little more detailed, I've discovered that this is even outside the onSuccess, when I do : const { mutateAsync: insertNewTeam } = useInsertMutation(...)
const data = await insertNewTeam(...)
// data has the following type:
// data: any[] | null |
Hey @damien-schneider, thanks for reporting! Can you share the version of cache helpers, supabase cli and all supabase packages? |
Yes of course, sorry, here are the versions used : "@tanstack/react-query": "^5.59.16",
"@supabase-cache-helpers/postgrest-react-query": "^1.10.1",
"@supabase/postgrest-js": "^1.16.3",
"@supabase/realtime-js": "^2.10.7",
"@supabase/ssr": "^0.1.0",
"@supabase/supabase-js": "^2.45.6",
"supabase": "^1.207.9", Do you have the types working with other dependencies versions? |
@psteinroe It seems you are using SWR instead of React Query. Is the useInsertMutation hook typed with the SWR package? This will help determine whether the errors originate from the React Query package or perhaps from the core itself. |
hey @damien-schneider, just checked the tests in this repo and the types are working there for the |
Thanks for your response! I tried reproducing the issue in this repository but couldn’t replicate it here, despite using the same versions of ![]() Additionally, I noticed another issue when trying to upgrade the I’ve created a branch to investigate this further, but I haven’t found a solution yet: Branch link: fix-@supabase/postgrest-js-upgrade-to-1.17 One example of the type errors is an issue with
It appears there are breaking changes in Also, this new version is being automatically included when using |
I've created a reproduction, with the database.type of the postgrest-react-query. https://stackblitz.com/edit/stackblitz-starters-jtuadg?file=app%2Fpage.tsx Tell me if you have difficulties opening the repro |
hey @damien-schneider, thanks for investigating! I think this is because of the "@supabase/postgrest-js": "1.9.0", in my project. I need to upgrade the types to work with latest postgrest-js. |
Thanks for looking into this! Since I’m new to the repo, this migration might be a bit complex for me, but let me know if there’s anything specific I can help with! |
I’ve spent about an hour trying to get the types working correctly with mutations, but I haven’t had any success. Do you have a repository where this is functioning properly?
|
hey @damien-schneider, sorry to hear that! can you make sure you are using the latest supabase cli version "@supabase/postgrest-js": "1.16.3", |
I'm encountering issues with type generation using the following dependencies:
Steps I've Tried:
Additional Observations:
SummaryDespite trying different versions of But, the type errors don't appear within the |
If someone have the types working correctly in a repo, whatever if it is |
can you share your tsconfig? |
In the stackblitz (here: https://stackblitz.com/edit/stackblitz-starters-jtuadg?file=app%2Fpage.tsx) this is the tsconfig : tsconfig.json{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
} |
hey @damien-schneider, I dont have the time right now to debug this but I noticed you have neither swr nor react query installed? these are required as a peer dependency. |
I temporarily removed it for some tests, but it was, of course, installed initially. I understand you don't have the time to debug this right now, but since you're likely using the library and it seems to be working for you, could you share the versions of the implicated packages you're using? That information would be really helpful. |
It's exactly the versions as well as the tsconfig files used in this repo. |
Okay, if it works locally, I’ll temporarily move the supabase-cache-helper into my monorepo while I investigate the issue. |
I also encountered the same problem, I solved the problem by making this change to the {
"compilerOptions": {
"moduleResolution": "node",
}
} https://stackblitz.com/edit/stackblitz-starters-dazcf4iy?file=app%2Fpage.tsx |
It's quite impossible to have |
I've investigated the issue and discovered that setting For example: import { GetResult } from '@supabase/postgrest-js/dist/cjs/select-query-parser/result';
import {
GenericSchema,
GenericTable,
} from '@supabase/postgrest-js/dist/cjs/types'; When Proposed Solution: Question:
|
Describe the bug
When using onSettled, onSuccess, etc The behaviour of react query is to type the data in the params, for now it seems only the variables param is typed, the data isn't (see screenshot)
To Reproduce
Create a double mutation with onSuccess behaviour.
Use the data of the first query in the second one, using the data, you'll normally see that the data is type as any[] instead of the query data which is normally handled by react query
Expected behavior
Should pass the type of the query
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: