Skip to content

Instantly share code, notes, and snippets.

@drejohnson
Created December 3, 2017 20:11
Show Gist options
  • Save drejohnson/31a9b474cfd93233a930cdba9a8a400b to your computer and use it in GitHub Desktop.
Save drejohnson/31a9b474cfd93233a930cdba9a8a400b to your computer and use it in GitHub Desktop.
type hoc = ReasonReact.reactClass => ReasonReact.reactClass;
[@bs.module "react-apollo"] external graphql : GraphQLTag.definitions => hoc = "graphql";
module type Query = {type data; let query: GraphQLTag.definitions;};
module CreateWrapper = (Query: Query) => {
type props = {. "data": Query.data};
let wrapComponent = (~component, ~make) => {
let jsComponent =
ReasonReact.wrapReasonForJs(
~component=component,
(props: props) => {
let data = props##data;
make(~data=data, [||]);
}
);
graphql(Query.query, jsComponent);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment