Skip to content

[Query] Type queryFn return instead of useQuery generic#2128

Open
jeesunikim wants to merge 7 commits into
mainfrom
issue-1914
Open

[Query] Type queryFn return instead of useQuery generic#2128
jeesunikim wants to merge 7 commits into
mainfrom
issue-1914

Conversation

@jeesunikim

@jeesunikim jeesunikim commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

See the official doc:

However, this has the drawback that type inference for all other generics of useQuery will not work anymore. It is generally not considered a good practice to throw something that isn't an Error, so if you have a subclass like AxiosError you can use type narrowing to make the error field more specific:

Move the result type from the useQuery<T> generic onto each queryFn
return annotation so TData is inferred from the function. Widen
useSEContractInfo's consumer prop to accept the now-accurate null.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 26, 2026 22:00
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Jun 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR shifts TanStack Query result typing from useQuery<T>() generics to explicit queryFn return annotations so TQueryFnData/TData are inferred from the function, and updates a smart-contract explorer consumer to accept null where the StellarExpert contract info query can legitimately return it.

Changes:

  • Removed useQuery<T>() generics across several query hooks and added explicit queryFn Promise<...> return annotations.
  • Updated StellarExpert/RPC query hooks to surface more accurate null possibilities via inference.
  • Widened ContractInfo’s infoData prop type to accept null in addition to undefined.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/query/useWasmGitHubAttestation.ts Moves useQuery result typing onto the queryFn return annotation.
src/query/useWasmBinaryFromRpc.ts Moves useQuery result typing onto the queryFn return annotation.
src/query/useMaintenanceData.ts Moves useQuery result typing onto the queryFn return annotation.
src/query/useGitHubReadmeText.ts Moves useQuery result typing onto the queryFn return annotation.
src/query/useGitHubFile.ts Moves useQuery result typing onto the queryFn return annotation.
src/query/useGetContractDataFromRpcById.ts Moves a complex useQuery result type onto the queryFn return annotation.
src/query/useContractClientFromRpc.ts Moves useQuery result typing onto the queryFn return annotation.
src/query/external/useSEContractWasmBinary.ts Moves useQuery result typing onto the queryFn return annotation.
src/query/external/useSEContractVersionHistory.ts Moves useQuery result typing onto the queryFn return annotation (including null).
src/query/external/useSEContractStorage.ts Moves useQuery result typing onto the queryFn return annotation (including null).
src/query/external/useSEContractsList.ts Moves useQuery result typing onto the queryFn return annotation.
src/query/external/useSEContractInfo.ts Moves useQuery result typing onto the queryFn return annotation (now accurately includes null).
src/app/(sidebar)/smart-contracts/contract-explorer/components/ContractInfo.tsx Updates infoData prop type to accept null from the refined query typing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/query/useWasmGitHubAttestation.ts Outdated
Comment thread src/query/useGetContractDataFromRpcById.ts
Comment thread src/query/useContractClientFromRpc.ts Outdated
Comment thread src/query/external/useSEContractsList.ts Outdated
Comment thread src/query/useMaintenanceData.ts
@stellar-jenkins-ci

Copy link
Copy Markdown

jeesunikim and others added 5 commits June 26, 2026 15:06
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@stellar-jenkins-ci

Copy link
Copy Markdown

1 similar comment
@stellar-jenkins-ci

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b8f9c5412

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/query/useMaintenanceData.ts Outdated
@stellar-jenkins-ci

Copy link
Copy Markdown

2 similar comments
@stellar-jenkins-ci

Copy link
Copy Markdown

@stellar-jenkins-ci

Copy link
Copy Markdown

Coercing a missing/non-array scheduled_maintenances to [] made a broken
API response indistinguishable from a valid empty schedule, silently
hiding the testnet reset-date warning. Throw instead so the failure
surfaces in the banner's error branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@stellar-jenkins-ci

Copy link
Copy Markdown

@jeesunikim jeesunikim requested a review from quietbits June 26, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

3 participants