Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Y = [%graphql {|
- mutation y($foo: String!) {
- y(foo: $bar) {
- bar
- }
- }
- |}];
- let component = ReasonReact.statelessComponent("Greeting");
- module Mutation = Apollo.Client.Mutation;
- let make = (_children) => {
- ...component,
- render: (_) => {
- <Mutation>
- ((mutate, response) => {
- let mutation = Y.make(~foo="bar", ());
- switch response {
- | NotCalled => {
- mutate(mutation);
- <div> (ReasonReact.stringToElement("Loading")) </div>
- }
- | Loading => <div> (ReasonReact.stringToElement("Loading")) </div>
- | Failed(error) => <div> (ReasonReact.stringToElement(error)) </div>
- | Loaded(result) => {
- let parse = mutation##parse;
- let bar = parse(result)##y;
- let o = Json.Decode.({
- "foo": bar |> field("foo", string)
- });
- }
- }})
- </Mutation>
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement