Guest User

Untitled

a guest
Jun 24th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import * as React from 'react'
  2. import { graphql } from 'react-apollo'
  3. import gql from 'graphql-tag'
  4.  
  5.  
  6. const USER_INFOMATION_QUERY = gql`
  7. query {
  8. user {
  9. _id
  10. email
  11. }
  12. }
  13. `
  14.  
  15. // create Query HOC
  16. const withUserQueryData = graphql(USER_INFOMATION_QUERY, {
  17. props: ({ data }) => {
  18. if(!data.user) { return {} }
  19. return {
  20. user: data.user
  21. }
  22. }
  23. })
  24.  
  25. type UserInfoComponentPropTypes = {
  26. user: UserInfoData
  27. }
  28. const UserInfoComponent: React.SFC<UserInfoComponentPropTypes> = () => { ....return some component }
  29.  
  30. // enhance with data
  31. export default withUserQueryData(UserInfoComponent)
Add Comment
Please, Sign In to add comment