import * as React from 'react' ; import { graphql , ChildProps } from 'react-apollo' ; import gql from 'graphql-tag' ; interface Result { repo : { id : number ; name : string ; description : string ; html_url : string ; } ; } interface OwnProps { name : string ; } type Props = ChildProps < OwnProps , Result > ; class RepoBase extends React . Component < Props , { } > { public render ( ) { const { data } = this . props ; if ( data && data . repo ) { return ( < div > < h3 > < a href = { data . repo . html_url } > { data . repo . name } < /a> < /h3> < p > { data . repo . description } < /p> < /div>); } else if ( data && data . loading ) { return < div > Loading ... < /div>; } else { return null ; } } } const query = gql `
  query Repo($name: String!) {
    repo(name: $name) @rest(type: "Repo", path: "/repos/apollographql/:name") {
      id
      name
      description
      html_url
    }
  }
` ; const Repo = graphql < Result , OwnProps > ( query , { options : ( { name } ) => ( { variables : { name } } ) , } ) ( RepoBase ) ; export { Repo } ;