Skip to content

Instantly share code, notes, and snippets.

@gregberge
Last active May 24, 2018 19:10
Show Gist options
  • Save gregberge/45235aabdba7beac31af594a787d32a2 to your computer and use it in GitHub Desktop.
Save gregberge/45235aabdba7beac31af594a787d32a2 to your computer and use it in GitHub Desktop.
FraQL preview πŸ‘Œ
import React from 'react'
import gql from 'fraql'
const ArticleCard = ({ article }) => (
<div>
<h1>{article.title}</h1>
<p>{article.description}</p>
</div>
)
ArticleCard.fragments = {
article: gql`
fragment _ on Article {
title
description
}
`
}
export default ArticleCard
import React from 'react'
import { Query } from 'apollo-client'
import gql from 'graphql-tag'
import ArticleCard from './ArticleCard'
const ARTICLES = gql`
query Articles {
articles {
id
${ArticleCard.fragments.article}
}
}
`
const ArticleList = ({ articles }) => (
<div>
<Query query={ARTICLES}>
{({ data }) => data.articles && data.articles.map(article => (
<ArticleCard key={article.id} article={article} />
))}
</Query>
</div>
)
export default ArticleList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment