Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as React from 'react'
- import { graphql } from 'react-apollo'
- import gql from 'graphql-tag'
- const USER_INFOMATION_QUERY = gql`
- query {
- user {
- _id
- email
- }
- }
- `
- // create Query HOC
- const withUserQueryData = graphql(USER_INFOMATION_QUERY, {
- props: ({ data }) => {
- if(!data.user) { return {} }
- return {
- user: data.user
- }
- }
- })
- type UserInfoComponentPropTypes = {
- user: UserInfoData
- }
- const UserInfoComponent: React.SFC<UserInfoComponentPropTypes> = () => { ....return some component }
- // enhance with data
- export default withUserQueryData(UserInfoComponent)
Add Comment
Please, Sign In to add comment