diff --git a/packages/ra-core/src/controller/field/ReferenceManyFieldBase.stories.tsx b/packages/ra-core/src/controller/field/ReferenceManyFieldBase.stories.tsx
index 78c8142bf4f..1f7f8a74b24 100644
--- a/packages/ra-core/src/controller/field/ReferenceManyFieldBase.stories.tsx
+++ b/packages/ra-core/src/controller/field/ReferenceManyFieldBase.stories.tsx
@@ -414,3 +414,46 @@ const AuthorList = ({ source }) => {
);
};
+
+// test queryOptions type, it should support onSuccess and onError
+export const QueryOptions = ({ dataProvider }) => (
+
+
+
+
+ console.log('Query successful'),
+ onError: () => console.log('Query failed'),
+ retry: false,
+ }}
+ >
+
+
+
+ }
+ />
+
+
+);
+
+QueryOptions.args = {
+ dataProvider: dataProviderWithAuthors,
+};
+
+QueryOptions.argTypes = {
+ dataProvider: {
+ control: { type: 'radio' },
+ options: ['No error', 'With Error'],
+ mapping: {
+ 'No error': dataProviderWithAuthors,
+ 'With Error': dataProviderWithAuthorsError,
+ },
+ },
+};
diff --git a/packages/ra-core/src/controller/field/useReferenceManyFieldController.ts b/packages/ra-core/src/controller/field/useReferenceManyFieldController.ts
index 5548ba1a728..fa7a0a2c5a5 100644
--- a/packages/ra-core/src/controller/field/useReferenceManyFieldController.ts
+++ b/packages/ra-core/src/controller/field/useReferenceManyFieldController.ts
@@ -5,7 +5,11 @@ import isEqual from 'lodash/isEqual.js';
import lodashDebounce from 'lodash/debounce.js';
import { removeEmpty, useEvent } from '../../util';
-import { useDataProvider, useGetManyReference } from '../../dataProvider';
+import {
+ useDataProvider,
+ useGetManyReference,
+ UseGetManyReferenceHookOptions,
+} from '../../dataProvider';
import { useNotify } from '../../notification';
import {
Exporter,
@@ -359,7 +363,7 @@ export const useReferenceManyFieldController = <
export interface UseReferenceManyFieldControllerParams<
RecordType extends Record = Record,
- ReferenceRecordType extends Record = Record,
+ ReferenceRecordType extends RaRecord = any,
ErrorType = Error,
> {
debounce?: number;
@@ -375,10 +379,7 @@ export interface UseReferenceManyFieldControllerParams<
storeKey?: string;
target: string;
queryOptions?: Omit<
- UseQueryOptions<
- { data: ReferenceRecordType[]; total: number },
- ErrorType
- >,
+ UseGetManyReferenceHookOptions,
'queryKey' | 'queryFn'
>;
}