Something went wrong. Try again.
Starship Simulator Controls thoriumsim.com
Something went wrong. Try again.
927 B · 26 lines
TypeScript
at develop
123456789101112131415161718192021222324252627/** * To allow easy interactions with groups of related queries, such as * invalidating all queries of a router, we use an array as the path when * storing in tanstack query. This function converts from the `.` separated * path passed around internally by both the legacy and proxy implementation. * https://github.com/trpc/trpc/issues/2611 */
export function getArrayQueryKey( queryKey: string | [string] | [string, ...unknown[]] | unknown[],): [string[], { input?: unknown }] { const queryKeyArrayed = Array.isArray(queryKey) ? queryKey : [queryKey]; const [path, input] = queryKeyArrayed;
const arrayPath = typeof path !== "string" || path === "" ? [] : path.split(".");
// Construct a query key that is easy to destructure and flexible for // partial selecting etc. // https://github.com/trpc/trpc/issues/3128 return [ arrayPath, { ...(typeof input !== "undefined" && { input: input }), }, ];}