aboutsummaryrefslogblamecommitdiffstats
path: root/webui/src/bug/BugQuery.js
blob: 2242141499f65969aa30edcb5a919f147be00e86 (plain) (tree)
1
2
3
4
5
6
7
8



                                                                 
 
                       

                  




                              



                 
 
 
                               


                                                         
                                             
                                                    

          
 
 
                       
import CircularProgress from '@material-ui/core/CircularProgress'
import gql from 'graphql-tag'
import React from 'react'
import { Query } from 'react-apollo'

import Bug from './Bug'

const QUERY = gql`
  query GetBug($id: String!) {
    defaultRepository {
      bug(prefix: $id) {
        ...Bug
      }
    }
  }

  ${Bug.fragment}
`

const BugQuery = ({match}) => (
  <Query query={QUERY} variables={{id: match.params.id}}>
    {({loading, error, data}) => {
      if (loading) return <CircularProgress/>
      if (error) return <p>Error: {error}</p>
      return <Bug bug={data.defaultRepository.bug}/>
    }}
  </Query>
)

export default BugQuery