Created
September 28, 2017 15:35
-
-
Save WesSouza/f18e6bb76075b345800737292ec48bc7 to your computer and use it in GitHub Desktop.
Choosing GraphQL for your API - React Component
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, { Component } from 'react'; | |
import { Link } from 'react-router-dom'; | |
// GraphQL libraries | |
import gql from 'graphql-tag'; | |
import { graphql } from 'react-apollo'; | |
// React magic here | |
class HeaderWishlist extends Component { ... } | |
// Query the user's wishlist | |
const WishlistQuery = gql`{ | |
wishlist { | |
meetups { | |
id | |
name | |
} | |
} | |
}`; | |
// Create the higher order component with that query | |
const withData = graphql(WishlistQuery); | |
// Export the plugged component | |
export default withData(HeaderWishlist); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment