UNPKG

rescript-relay

Version:
47 lines (40 loc) 1.91 kB
// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; let RelayRuntime = require("relay-runtime"); let RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js"); function fetch_(node, convertResponse, convertVariables) { return (environment, variables, onResult, networkCacheConfig, fetchPolicy) => { RelayRuntime.fetchQuery(environment, node, RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(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, RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(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, RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertVariables(variables)))); } function commitLocalPayload(node, convertVariables, convertWrapRawResponse) { return (environment, variables, payload) => { environment.commitPayload(RelayRuntime.createOperationDescriptor(node, RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertVariables(variables))), convertWrapRawResponse(payload)); }; } exports.fetch_ = fetch_; exports.fetchPromised = fetchPromised; exports.retain = retain; exports.commitLocalPayload = commitLocalPayload; /* relay-runtime Not a pure module */