React Relay Uncaught RelayNetwork: No data returned for operation
Asked Answered
E

1

6

I am seeing this error:

Uncaught RelayNetwork: No data returned for operation

in my application. I am using Relay Modern with "relay-runtime": "1.7.0"

The question i am having is how to catch these errors. I feel no matter where i place my try/catch, this error keeps eluding me.

e.g.

const mutation = graphql`
    mutation MyMutation($input: UpdateMe!) {
        updateSomething(input: $input) {
            article {
                ...things_stuff
            }
        }
    }
`;

export default ({
    rowId,
    ...patch
}: Patch): Promise<GreatTypes> =>
    new Promise((resolve, reject) => {
        commitMutation(environment, {
            mutation,
            variables: {
                id,
            },
            onCompleted: (resp, err) => {
                if (err) {
                    console.log('onCompleted @ sdfg');
                    return reject(err);
                }
                return resolve(resp);
            },
            onError: err => {
                console.log('onError @ sdfg');
                return reject(err);
            },
        });
    });
Explosive answered 17/1, 2020 at 13:53 Comment(1)
did you check your graphql endpoint is being called with front end?Emblements
E
-1

I had the same error and what ended up being the issue for me was that I was using axios as the base api client for fetching graphql and my return was incorrect. After the post call I had to return response.data

const client = getAxiosClient();
const res = await client.post("", query);
return res.data;

A few other issues I resolved were found by mimicking the configuration from this link: https://relay.dev/docs/getting-started/step-by-step-guide/

Eoin answered 18/8, 2022 at 14:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.