Last active
September 11, 2018 19:43
-
-
Save arnabkd/0126d7dae11d537874f12bd6ee0669f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { PropTypes } from 'prop-types' | |
import { Query } from 'react-apollo' | |
import gql from 'graphql-tag' | |
const Speaker = ({match}) => { | |
Speaker.Proptypes = { | |
match: PropTypes.shape({ | |
params: PropTypes.shape({ | |
id: PropTypes.String | |
}) | |
}) | |
} | |
const GET_SPEAKER_QUERY = gql` | |
query($id: ID){ | |
speaker(where: {id: $id}) { | |
id | |
name | |
} | |
} | |
` | |
const variables = {'id': match.params.id } | |
return ( | |
<Query query={GET_SPEAKER_QUERY} variables={variables}> | |
{({loading, error, data}) => { | |
if (loading) return <p> loading... </p> | |
if (error) return <p> error...</p> | |
return ( | |
<p>{data.speaker}</p> | |
) | |
}} | |
</Query> | |
) | |
} | |
export default Speaker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment