I am trying to setup RTK Query and have some troubles with defining a tag-id.
No matter what I try, I cannot seem to make the "Timeseries" tag work with an id.
Here is my api:
export type GetTimeseriesProps = {
datasource: InsightshubDataSource
from: string,
to: string
}
export const valuesightApi = createApi({
reducerPath: "valuesightQuery",
baseQuery: fetchBaseQuery({ baseUrl: import.meta.env.VITE_VALUESIGHT_BACKEND_URL }),
tagTypes: ['Dashboard', 'Timeseries'],
endpoints: (builder) => ({
getDashboardById: builder.query<Dashboard, void>({
query: (id) => `/vsapi/Dashboard/${id}`,
providesTags: (result, error, arg) => [
{ type: 'Dashboard', id: Number(arg) },
]
}),
getTimeseriesFromTo: builder.query<TimeSeriesData[], GetTimeseriesProps>({
query: (props) => ({
url: `/vsapi/Timeseries/${props.datasource.assetId}/${props.datasource.aspectName}/${props.datasource.variableName}`,
method: 'GET',
params: {
from: props.from,
to: props.to
}
}),
providesTags: (result, error, arg) => [{
type: 'Timeseries',
id: String(arg.datasource.assetId)
}]
}),
}),
});
Whenever I make a new Timeseries query, it automatically gets the entire parameter (arg) object as id, NOT just the arg.datasource.assetId.
This works fine with the dashboard however as I can see in the RTK Query tab in the extension:
So the same thing happens if I dont provide an Id, so it seems like it cant parse the args for some reason

The tags are only used for query/mutation endpoint validations.
See:
The query endpoints can provide specific tags, and the mutation endpoints can invalidate them and trigger queries to automatically re-run.
What you are looking at in the Redux-Devtools however are not the tags, these are the query cache keys. The cache keys are part of Redux-Toolkit Query's "publish/subscribe" mechanism.
See
serializeQueryArgs:Here I've marked the provided cache tags in green, and the query cache keys in red. You can see the current queries and subscriptions using the query cache keys, and the provided tags map specific tags to specific query cache keys.
You can provide your own custom cache keys however, using the
createApi'sserializeQueryArgsfunction (description quoted above), or each endpoint'sserializeQueryArgsfunction (below).