Skip to content

Commit ba16dc2

Browse files
committed
feat: remove automatically inspect primary key
1 parent 400d7f8 commit ba16dc2

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

src/createBaseQuery.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,12 @@ type QueryBaseHookOptions = Omit<
2121
variables?: any
2222
}
2323

24-
const existedPrimaryKeys = new Set<string>()
25-
2624
export const createBaseQuery = (
2725
defaultOptions: any,
2826
useRQHook: (options: any, queryClient?: any) => any,
2927
overrideOptions?: QueryBaseHookOptions
3028
): any => {
31-
const {
32-
primaryKey,
33-
queryFn,
34-
queryKeyHashFn,
35-
getPreviousPageParam,
36-
getNextPageParam,
37-
initialPageParam,
38-
} = defaultOptions as CreateBaseQueryOptions
39-
4029
if (process.env.NODE_ENV !== 'production') {
41-
if (existedPrimaryKeys.has(primaryKey)) {
42-
console.error(`[Bug] Duplicated primaryKey: ${primaryKey}`)
43-
} else {
44-
existedPrimaryKeys.add(primaryKey)
45-
}
46-
4730
// @ts-ignore
4831
if (defaultOptions.useDefaultOptions) {
4932
console.error(
@@ -52,6 +35,15 @@ export const createBaseQuery = (
5235
}
5336
}
5437

38+
const {
39+
primaryKey,
40+
queryFn,
41+
queryKeyHashFn,
42+
getPreviousPageParam,
43+
getNextPageParam,
44+
initialPageParam,
45+
} = defaultOptions as CreateBaseQueryOptions
46+
5547
const getPrimaryKey = () => primaryKey
5648

5749
const getKey = (variables?: any) => getQueryKey(primaryKey, variables)

src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const suspenseOptions = {
3939
enabled: true,
4040
suspense: true,
4141
throwOnError: true,
42+
// Compatible with ReactQuery v4
4243
useErrorBoundary: true,
4344
}
4445

0 commit comments

Comments
 (0)