Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bitter-mails-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@genseki/react-query': patch
---

Remove `header` object from query key
13 changes: 2 additions & 11 deletions packages/react-query/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type {
} from '@genseki/react'
import { createRestClient, type CreateRestClientConfig } from '@genseki/rest'

import { isEmptyObject, normalizeObject, sortObjectDeep } from './utils'
import { normalizeObject } from './utils'

type QueryMethod = 'GET'
type MutationMethod = 'POST' | 'PATCH' | 'PUT' | 'DELETE'
Expand Down Expand Up @@ -216,17 +216,8 @@ export function queryKey(method: string, path: string | number | symbol, payload
return [method, path] as const
}

const { header, ...rest } = payload
const { header: _header, ...rest } = payload
const normalizedPayload = normalizeObject(rest)
const normalizedHeaders = header && !isEmptyObject(header) ? sortObjectDeep(header) : undefined

if (normalizedHeaders && normalizedPayload) {
return [method, path, normalizedPayload, normalizedHeaders] as const
}

if (normalizedHeaders) {
return [method, path, normalizedHeaders] as const
}

if (normalizedPayload) {
return [method, path, normalizedPayload] as const
Expand Down
Loading