@illusionalsagacity/rescript-msw
Version:
ReScript bindings for MSW
97 lines (88 loc) • 2.3 kB
JavaScript
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Msw from "msw";
import * as Js_dict from "rescript/lib/es6/js_dict.js";
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
function serialize($$location) {
return Js_dict.fromArray([
[
"line",
$$location.line
],
[
"column",
$$location.column
]
]);
}
var $$Location = {
serialize: serialize
};
function serialize$1(error) {
var extensions = Belt_Option.map(error.extensions, (function (prim) {
return prim;
}));
var locations = error.locations;
var locations$1 = locations !== undefined ? locations.map(serialize) : undefined;
var path = Belt_Option.map(error.path, (function (prim) {
return prim;
}));
var message = error.message;
var err = Js_dict.fromArray([[
"message",
message
]]);
if (locations$1 !== undefined) {
err["locations"] = locations$1;
}
if (path !== undefined) {
err["path"] = path;
}
if (extensions !== undefined) {
err["extensions"] = extensions;
}
return err;
}
var GraphQLError = {
serialize: serialize$1
};
function Make(Operation) {
var serialize$2 = function (data, errors, extensions) {
var body = Js_dict.fromArray([[
"data",
Operation.serialize(data)
]]);
if (errors !== undefined) {
body["errors"] = errors.map(serialize$1);
}
if (extensions !== undefined) {
body["extensions"] = extensions;
}
return body;
};
var graphql = function (data, errors, extensions, httpResponseInit) {
return Msw.HttpResponse.json(serialize$2(data, errors, extensions), httpResponseInit);
};
return {
graphql: graphql
};
}
function graphql(data, errors, extensions, httpResponseInit) {
var body = Js_dict.fromArray([[
"data",
data
]]);
if (errors !== undefined) {
body["errors"] = errors.map(serialize$1);
}
if (extensions !== undefined) {
body["extensions"] = extensions;
}
return Msw.HttpResponse.json(body, httpResponseInit);
}
export {
$$Location ,
GraphQLError ,
Make ,
graphql ,
}
/* msw Not a pure module */