Skip to content

[BUG] Using GraphQL as the data provider, Refines hooks like useUpdate, onMutationSuccess, onSuccess, etc return undefined data #6600

Closed
@maximdolphin

Description

@maximdolphin

Describe the bug

I am trying to make a form submission with Refine, and for some reason anytime I try to receive the data from the mutation, it returns it as undefined but says the mutation was successful. Here's what my backend returns for instance:
{
"id": 37,
"title": "schedule",
"semesterId": "Spring 2025",
"entries": []
}

Steps To Reproduce

    const {formProps, modalProps, close, mutationResult} = useModalForm({
            action: "create",
            defaultVisible: true,
            meta: {
                select: "*",
                gqlMutation: CREATE_CLASS_SCHEDULE_MUTATION,
            },
        onMutationSuccess: (response) => {
            console.log('Full response:', response);
            const createdSchedule = response?.data?.createClassSchedule;
            if (createdSchedule) {
                console.log('Created schedule:', createdSchedule);
                onFinish(createdSchedule as ClassSchedule);
                close();
                onClose();
            } else {
                console.error('Created schedule data is missing from the response');
            }
        },
            onMutationError: () => {
                throw new Error("Failed to create schedule");
            },
        }
    );

Expected behavior

The data should've returned in that aforementioned style, but yet it keeps returning data undefined and context undefined

Packages

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions