rescript-relay
Version:
Use Relay with ReScript.
46 lines (39 loc) • 1.59 kB
JavaScript
// Generated by ReScript, PLEASE EDIT WITH CARE
;
let RelayRuntime = require("relay-runtime");
function fetch(node, convertResponse, convertVariables) {
return (environment, variables, onResult, networkCacheConfig, fetchPolicy) => {
RelayRuntime.fetchQuery(environment, node, convertVariables(variables), {
networkCacheConfig: networkCacheConfig,
fetchPolicy: fetchPolicy
}).subscribe({
next: res => onResult({
TAG: "Ok",
_0: convertResponse(res)
}),
error: err => onResult({
TAG: "Error",
_0: err
})
});
};
}
function fetchPromised(node, convertResponse, convertVariables) {
return (environment, variables, networkCacheConfig, fetchPolicy) => RelayRuntime.fetchQuery(environment, node, convertVariables(variables), {
networkCacheConfig: networkCacheConfig,
fetchPolicy: fetchPolicy
}).toPromise().then(res => Promise.resolve(convertResponse(res)));
}
function retain(node, convertVariables) {
return (environment, variables) => environment.retain(RelayRuntime.createOperationDescriptor(node, convertVariables(variables)));
}
function commitLocalPayload(node, convertVariables, convertWrapRawResponse) {
return (environment, variables, payload) => {
environment.commitPayload(RelayRuntime.createOperationDescriptor(node, convertVariables(variables)), convertWrapRawResponse(payload));
};
}
exports.fetch = fetch;
exports.fetchPromised = fetchPromised;
exports.retain = retain;
exports.commitLocalPayload = commitLocalPayload;
/* relay-runtime Not a pure module */