@wildcards/reason-apollo
Version:
Using Apollo client 2 with Reason
48 lines (42 loc) • 1.48 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) {
return apolloDataToRecord(client.readQuery(/* record */[
/* query */graphqlQueryAST,
/* variables */Js_null_undefined.fromOption(variables)
]));
};
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(/* record */[
/* 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 */