5

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);
            },
        });
    });
Divide by Zero
  • 1,343
  • 1
  • 14
  • 37

1 Answers1

0

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/