reason-apollo
Version:
Using Apollo client 2 with Reason
49 lines (43 loc) • 1.5 kB
JavaScript
// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE
import * as Belt_Option from "bs-platform/lib/es6/belt_Option.js";
import * as Caml_option from "bs-platform/lib/es6/caml_option.js";
import * as GraphqlTag from "graphql-tag";
import * as Js_null_undefined from "bs-platform/lib/es6/js_null_undefined.js";
function ReadQuery(Config) {
var graphqlQueryAST = GraphqlTag.default(Config.query);
var apolloDataToRecord = function (apolloData) {
return Belt_Option.map((apolloData == null) ? undefined : Caml_option.some(apolloData), Config.parse);
};
var make = function (client, variables, param) {
var apolloData = client.readQuery({
query: graphqlQueryAST,
variables: Js_null_undefined.fromOption(variables)
});
return Belt_Option.map((apolloData == null) ? undefined : Caml_option.some(apolloData), Config.parse);
};
return {
graphqlQueryAST: graphqlQueryAST,
apolloDataToRecord: apolloDataToRecord,
make: make
};
}
function WriteQuery(Config) {
var graphqlQueryAST = GraphqlTag.default(Config.query);
var make = function (client, variables, data, param) {
client.writeQuery({
query: graphqlQueryAST,
variables: Js_null_undefined.fromOption(variables),
data: data
});
return /* () */0;
};
return {
graphqlQueryAST: graphqlQueryAST,
make: make
};
}
export {
ReadQuery ,
WriteQuery ,
}
/* graphql-tag Not a pure module */