Relay Modern Fetch Function
const fetchFunction = async (
request: RequestNode,
variables: Variables,
cacheConfig: CacheConfig,
uploadables: ?UploadableMap,
) => {
const body = JSON.stringify({
query: request.text, // GraphQL text from input
variables,
});
const headers = {
Accept: 'application/json',
'Content-type': 'application/json',
authorization: getToken(),
};
const response = await fetchWithRetries(ENV.GRAPHQL_URL, {
method: 'POST',
headers,
body,
fetchTimeout: 20000,
retryDelays: [1000, 3000, 5000, 10000],
});
const data = await response.json();
if (isMutation(request) && data.errors) {
throw data;
}
return data;
};