graphql-yoga
Version:
<div align="center"><img src="./website/public/cover.png" width="720" /></div>
25 lines (24 loc) • 1.11 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.processRegularResult = void 0;
const utils_1 = require("@graphql-tools/utils");
const error_js_1 = require("../../error.js");
const stringify_js_1 = require("./stringify.js");
function processRegularResult(executionResult, fetchAPI, acceptedHeader) {
if ((0, utils_1.isAsyncIterable)(executionResult)) {
return new fetchAPI.Response(null, {
status: 406,
statusText: 'Not Acceptable',
headers: {
accept: 'application/json; charset=utf-8, application/graphql-response+json; charset=utf-8',
},
});
}
const headersInit = {
'Content-Type': acceptedHeader + '; charset=utf-8',
};
const responseInit = (0, error_js_1.getResponseInitByRespectingErrors)(executionResult, headersInit, acceptedHeader === 'application/json');
const responseBody = (0, stringify_js_1.jsonStringifyResult)(executionResult);
return new fetchAPI.Response(responseBody, responseInit);
}
exports.processRegularResult = processRegularResult;
;