Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Create a GraphQL Query by using the graphql_ppx */
- module PostsQuery = [%graphql {|
- query {
- allPostOffers {
- id
- title
- body
- }
- }
- |}];
- let component = ReasonReact.statelessComponent("Greeting");
- module Query = Apollo.Client.Query;
- let make = (_children) => {
- ...component,
- render: (_) => {
- let unexpectedError = <div> (ReasonReact.stringToElement("There was an internal error")) </div>;
- let PostsQuery = PostsQuery.make(());
- <Query query=PostsQuery>
- ((response, parse) => {
- switch response {
- | Loading => <div> (ReasonReact.stringToElement("Loading")) </div>
- | Failed(error) => <div> (ReasonReact.stringToElement(error)) </div>
- | Loaded(result) => {
- <div>
- (
- ReasonReact.arrayToElement(
- Array.map(((PostOffer) => <div key=(PostOffer##id)>
- (ReasonReact.stringToElement(PostOffer##title))</div>),
- response##data##allPostOffers)
- )
- )
- </div>
- }
- }})
- </Query>
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement