Skip to content

Commit

Permalink
feat(code-gen): support Updater in RQ setQueryData
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkdev98 committed Jan 9, 2024
1 parent c66bb47 commit 7ba289b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions examples/react-fetch/src/App.tsx
@@ -1,11 +1,10 @@
import { keepPreviousData } from "@tanstack/react-query";
import { useEffect, useState } from "react";
import { useEffect } from "react";
import "./App.css";
import { useEmojisEmojisGet } from "./generated/emojis/reactQueries.tsx";
import {
fetchWithBaseUrl,
setFetchFn,
} from "./generated/common/api-client.tsx";
import { useEmojisEmojisGet } from "./generated/emojis/reactQueries.tsx";

function App() {
useEffect(() => {
Expand Down
5 changes: 4 additions & 1 deletion packages/code-gen/src/api-client/react-query.js
Expand Up @@ -161,6 +161,7 @@ export function reactQueryGetApiClientFile(generateContext, route) {

// @tanstack/react-query imports
importCollector.destructure("@tanstack/react-query", "QueryKey");
importCollector.destructure("@tanstack/react-query", "Updater");
importCollector.destructure("@tanstack/react-query", "UseMutationOptions");
importCollector.destructure("@tanstack/react-query", "UseMutationResult");
importCollector.destructure("@tanstack/react-query", "UseQueryOptions");
Expand Down Expand Up @@ -607,7 +608,9 @@ ${hookName}.setQueryData = (
})},`
: ""
}
data: ${contextNames.responseTypeName ?? "unknown"},
data: Updater<${contextNames.responseTypeName ?? "unknown"}, ${
contextNames.responseTypeName ?? "unknown"
}>,
) => {
${reactQueryCheckIfRequiredVariablesArePresent(
generateContext,
Expand Down

0 comments on commit 7ba289b

Please sign in to comment.