Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.97 KB | None | 0 0
  1.  
  2. module Y = [%graphql {|
  3.     mutation y($foo: String!) {
  4.         y(foo: $bar) {
  5.           bar
  6.         }
  7.       }
  8. |}];
  9.      
  10. let component = ReasonReact.statelessComponent("Greeting");
  11. module Mutation = Apollo.Client.Mutation;
  12.  
  13. let make = (_children) => {
  14. ...component,
  15. render: (_) => {    
  16.     <Mutation>
  17.     ((mutate, response) => {
  18.       let mutation = Y.make(~foo="bar", ());        
  19.       switch response {
  20.          | NotCalled => {
  21.             mutate(mutation);
  22.             <div> (ReasonReact.stringToElement("Loading")) </div>
  23.          }
  24.          | Loading => <div> (ReasonReact.stringToElement("Loading")) </div>
  25.          | Failed(error) => <div> (ReasonReact.stringToElement(error)) </div>
  26.          | Loaded(result) => {
  27.              let parse = mutation##parse;
  28.              let bar = parse(result)##y;
  29.              let o = Json.Decode.({
  30.                 "foo": bar |> field("foo", string)
  31.               });
  32.          }
  33.     }})
  34.   </Mutation>
  35. }
  36. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement