-
Notifications
You must be signed in to change notification settings - Fork 0
/
PostList.js
42 lines (40 loc) · 1.04 KB
/
PostList.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from 'react';
import {Text, View} from 'react-native';
import {graphql} from 'react-apollo';
import gql from 'graphql-tag';
// The data prop, which is provided by the wrapper below contains,
// a `loading` key while the query is in flight and posts when ready
function PostList({data: {loading, allPosts}}) {
if (loading) {
return <Text>Loading</Text>;
} else {
return (
<View>
{allPosts.map(post => (
<View key={post.id}>
<Text>{post.description}</Text>
</View>
))}
</View>
);
}
}
// The `graphql` wrapper executes a GraphQL query and makes the results
// available on the `data` prop of the wrapped component (PostList here)
export default graphql(gql`
query allPosts {
allPosts {
id
description
imageUrl
}
}
`)(PostList);// =============================================================
//
// Name: PostList
// -> Description:
//
// Author: mitramejia
// Created at: 8/6/17
//
// =============================================================