Skip to content

Instantly share code, notes, and snippets.

@WesSouza
Created September 28, 2017 15:35
Show Gist options
  • Save WesSouza/f18e6bb76075b345800737292ec48bc7 to your computer and use it in GitHub Desktop.
Save WesSouza/f18e6bb76075b345800737292ec48bc7 to your computer and use it in GitHub Desktop.
Choosing GraphQL for your API - React Component
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