|
|
@@ -16,7 +16,11 @@ import { FormEvent } from 'react';
|
|
|
import { UseFormReturn } from 'react-hook-form';
|
|
|
|
|
|
import { addCustomFields } from '../document-introspection/add-custom-fields.js';
|
|
|
-import { getMutationName, getQueryName } from '../document-introspection/get-document-structure.js';
|
|
|
+import {
|
|
|
+ getEntityName,
|
|
|
+ getMutationName,
|
|
|
+ getQueryName,
|
|
|
+} from '../document-introspection/get-document-structure.js';
|
|
|
import { useGeneratedForm } from '../form-engine/use-generated-form.js';
|
|
|
|
|
|
import { DetailEntityPath } from './page-types.js';
|
|
|
@@ -65,8 +69,9 @@ export interface DetailPageOptions<
|
|
|
* @description
|
|
|
* The entity type name for custom field configuration lookup.
|
|
|
* Required to filter out readonly custom fields before mutations.
|
|
|
+ * If not provided, the function will try to infer it from the query document.
|
|
|
*/
|
|
|
- entityName: string;
|
|
|
+ entityName?: string;
|
|
|
/**
|
|
|
* @description
|
|
|
* The document to create the entity.
|
|
|
@@ -246,7 +251,8 @@ export function useDetailPage<
|
|
|
} = options;
|
|
|
const isNew = params.id === NEW_ENTITY_PATH;
|
|
|
const queryClient = useQueryClient();
|
|
|
- const customFieldConfig = useCustomFieldConfig(entityName);
|
|
|
+ const returnEntityName = entityName ?? getEntityName(queryDocument);
|
|
|
+ const customFieldConfig = useCustomFieldConfig(returnEntityName);
|
|
|
const detailQueryOptions = getDetailQueryOptions(addCustomFields(queryDocument), {
|
|
|
id: isNew ? '__NEW__' : params.id,
|
|
|
});
|