Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(openapi-react-query): add prefixQueryKey option#2357

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jeiea wants to merge1 commit intoopenapi-ts:main
base:main
Choose a base branch
Loading
fromjeiea:feat/prefix-query-key-2

Conversation

jeiea
Copy link

Background

Close#1979.

Current openapi-react-query has a potential issue becauseuseQuery calls from different clients are assigned the same key, even though they're querying different endpoints.

For example:

import{defaultascreateFetchClient}from'openapi-fetch'importcreateClientfrom'openapi-react-query'constclient1=createClient(createFetchClient({baseUrl:'https://api1.example.com'}))constclient2=createClient(createFetchClient({baseUrl:'https://api2.example.com'}))functionuseSomething(){return[client1.useQuery('get','/a'),client2.useQuery('get','/a')]}

Here, both queries receive the same key, even though they are querying different sources.

This try to resolve the problem.

Changes

  • Added aprefixQueryKey parameter to differentiate cache identities.

How to Review

  • I haven't changed the documentation, but if you think it's necessary, please comment.
  • I gotthe comment about prefixQueryKey's type, and I ended up usingunknown type.
    Seepackages/openapi-react-query/test/index.test.tsx:270, and feel free to leave a comment if you have any other thoughts.

Checklist

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

RobertBjorklundDev reacted with hooray emoji
@jeieajeiea requested a review froma team as acode ownerJune 14, 2025 16:58
@jeieajeiea requested a review fromhtunnicliffJune 14, 2025 16:58
@netlifyNetlify
Copy link

netlifybot commentedJun 14, 2025

👷 Deploy request foropenapi-ts pending review.

Visit the deploys page to approve it

NameLink
🔨 Latest commit1f048dc

@changeset-botchangeset-bot
Copy link

🦋 Changeset detected

Latest commit:1f048dc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
openapi-react-queryMinor

Not sure what this means?Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@RobertBjorklundDev
Copy link

RobertBjorklundDev commentedJul 4, 2025
edited
Loading

Awesome that this is on the way, I'm facing the same problem right now in my code and the only good option is to have an easy way of prefixing the queryKeys for a specific client!

@jeiea
Copy link
Author

@htunnicliff@kerwanp Please give me any kind of comments.

What’s your first impression of this PR? Are there any immediate concerns? Would you prefer to explore a different direction?

Even if you’re still thinking it through, it’d be great if you could share your thoughts.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@htunnicliffhtunnicliffAwaiting requested review from htunnicliffhtunnicliff is a code owner automatically assigned from openapi-ts/maintainers

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

feat(react-query): Add client parameter to queryKey and remove options parameter
2 participants
@jeiea@RobertBjorklundDev

[8]ページ先頭

©2009-2025 Movatter.jp