Skip to content
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

Add v5 generator #179

Merged
merged 6 commits into from
Jul 2, 2023
Merged

Add v5 generator #179

merged 6 commits into from
Jul 2, 2023

Conversation

rajzik
Copy link
Contributor

@rajzik rajzik commented Jun 27, 2023

Fixes #176

Added generator for react query V5

@fabien0102
Copy link
Owner

Hey,
First of all, thanks for the PR!
Looking at the migration guide from react-query https://tanstack.com/query/v5/docs/react/guides/migrating-to-v5 they did remove some signatures.
This means, if I’m following properly that the v5 object version should work with the v4. In this case, let’s just update to the object signature, and we should be good to go 😃

The underline idea is to keep this project as easy as possible, it’s a side project so if I don’t have to maintain multiple version of react-query, this would be amazing 😁

@rajzik
Copy link
Contributor Author

rajzik commented Jun 27, 2023

Oh I see, I will change it tomorrow and test it on our project.

@rajzik
Copy link
Contributor Author

rajzik commented Jun 28, 2023

Ok, the object signature works fine, I've update the PR, feel free to add any comments to it, so I can fix it.
If the PR is fine I would love to see this released soon. Thank you.

Copy link
Owner

@fabien0102 fabien0102 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@rajzik
Copy link
Contributor Author

rajzik commented Jun 29, 2023

I can see that pipeline failed, in repo is package lock and pipeline uses yarn, should I change package lock to yarn lock and commit?

@fabien0102
Copy link
Owner

fabien0102 commented Jul 2, 2023

I can see that pipeline failed, in repo is package lock and pipeline uses yarn, should I change package lock to yarn lock and commit?

Oh no, wait, let’s just fix the pipeline to use the same thing

@fabien0102 fabien0102 merged commit e1076af into fabien0102:main Jul 2, 2023
1 check passed
@github-actions github-actions bot mentioned this pull request Jul 2, 2023
@essuraj
Copy link

essuraj commented Jul 3, 2023

this version works with react query 4 but fails with react query 5 ( tested with "@tanstack/react-query": "5.0.0-alpha.71" )

No overload matches this call.
  Overload 1 of 2, '(options: UndefinedInitialDataOptions<string, GetHeartbeatError, TData, QueryKey>, queryClient?: QueryClient | undefined): UseQueryResult<...>', gave the following error.
    Argument of type '{ enabled?: boolean | undefined; staleTime?: number | undefined; refetchInterval?: number | false | ((data: TData | undefined, query: Query<string, GetHeartbeatError, string, QueryKey>) => number | ... 1 more ... | undefined) | undefined; ... 25 more ...; queryFn: ({ signal }: { ...; }) => Promise<...>; }' is not assignable to parameter of type 'UndefinedInitialDataOptions<string, GetHeartbeatError, TData, QueryKey>'.
      Type '{ enabled?: boolean | undefined; staleTime?: number | undefined; refetchInterval?: number | false | ((data: TData | undefined, query: Query<string, GetHeartbeatError, string, QueryKey>) => number | ... 1 more ... | undefined) | undefined; ... 25 more ...; queryFn: ({ signal }: { ...; }) => Promise<...>; }' is not assignable to type '{ initialData?: undefined; }'.
        Types of property 'initialData' are incompatible.
          Type 'string | InitialDataFunction<string> | undefined' is not assignable to type 'undefined'.
            Type 'string' is not assignable to type 'undefined'.
  Overload 2 of 2, '(options: DefinedInitialDataOptions<string, GetHeartbeatError, TData, QueryKey>, queryClient?: QueryClient | undefined): DefinedUseQueryResult<...>', gave the following error.
    Argument of type '{ enabled?: boolean | undefined; staleTime?: number | undefined; refetchInterval?: number | false | ((data: TData | undefined, query: Query<string, GetHeartbeatError, string, QueryKey>) => number | ... 1 more ... | undefined) | undefined; ... 25 more ...; queryFn: ({ signal }: { ...; }) => Promise<...>; }' is not assignable to parameter of type 'DefinedInitialDataOptions<string, GetHeartbeatError, TData, QueryKey>'.
      Type '{ enabled?: boolean | undefined; staleTime?: number | undefined; refetchInterval?: number | false | ((data: TData | undefined, query: Query<string, GetHeartbeatError, string, QueryKey>) => number | ... 1 more ... | undefined) | undefined; ... 25 more ...; queryFn: ({ signal }: { ...; }) => Promise<...>; }' is not assignable to type '{ initialData: string | (() => string); }'.
        Types of property 'initialData' are incompatible.
          Type 'string | InitialDataFunction<string> | undefined' is not assignable to type 'string | (() => string)'.
            Type 'undefined' is not assignable to type 'string | (() => string)'.

What did i do?

  • upgrade this plugin to v7
  • rebuild codegen files (no issues)
  • update react-query to v5 alpha
  • above errors in code per api
    image

@fabien0102-crabnebula
Copy link

At least this is not breaking react-query v4, sorry for bad review!

@rajzik
Copy link
Contributor Author

rajzik commented Jul 11, 2023

I think this is issue of RQ, UseQueryOptions should be assignable to the useQuery hook, I've opened issue in tanstack/query TanStack/query#5696

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for react query 5
4 participants