index.tsx
866 Bytes
import Component from "./Component";
import * as React from "react";
import { graphql, Query, Mutation } from "react-apollo";
import { withRouter, RouteComponentProps } from "react-router";
const FETCH_ORG = require("./fetchOrg.gql");
interface Props {
org: any;
}
class FetchContractQuery extends Query<Props> {}
const update = (history: any) => (cache, result) => history.goBack();
const QueryComponent: React.SFC<RouteComponentProps<{}> & Props> = props => (
<FetchContractQuery
query={FETCH_ORG}
fetchPolicy="network-only"
variables={{ id: props.match.params["id"] }}
>
{({ loading, error, data }) => {
if (loading) return <p>Loading...</p>;
else if (error || !data!.org) return <p>Error :(</p>;
else return <Component org={data!.org} />;
}}
</FetchContractQuery>
);
export default withRouter(QueryComponent);