Skip to content

react-query createQueryKey uses baseUrl of global client rather than options.client #987

@coltondotio

Description

@coltondotio

Description

The problem lies here:
https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/%40tanstack/query-core/plugin.ts#L118

In the below line of generated code, baseUrl is set to client.getConfig().baseUrl, using the global client variable.

const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey<TOptions>[0];

This should instead be something like:

const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0];

which pulls the baseUrl from options.client, if present.

Reproducible example or configuration

No response

OpenAPI specification (optional)

No response

System information (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Broken or incorrect behavior.important 📌This issue is important and will be addressed when capacity allows.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions