File tree 2 files changed +62
-0
lines changed
2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" App o-container o-container--s o-vertical-spacing o-vertical-spacing--xl" >
3
3
<h1 >How to Use GraphQL with Vue Apollo Components and Netlify Functions</h1 >
4
+ <ApolloQuery
5
+ :query =" require('./queries/articles.gql')"
6
+ >
7
+ <template slot-scope="{ result: { loading, error, data } }">
8
+ <div v-if =" loading" >
9
+ Loading...
10
+ </div >
11
+ <div v-else-if =" error" >
12
+ An error occured! Please try again.
13
+ </div >
14
+ <ul
15
+ v-else-if =" data"
16
+ class =" App__article-list"
17
+ >
18
+ <li
19
+ v-for =" article in data.articles"
20
+ :key =" article.id"
21
+ class =" App__article-list-item"
22
+ >
23
+ <div class =" App__article-list-figure" >
24
+ <img
25
+ :src =" article.image"
26
+ alt =" "
27
+ >
28
+ </div >
29
+ <div class =" App__article-list-body" >
30
+ <h2 >
31
+ {{ article.title }}
32
+ </h2 >
33
+ <p >
34
+ {{ article.body }}
35
+ </p >
36
+ </div >
37
+ </li >
38
+ </ul >
39
+ <div v-else >
40
+ There are no articles yet. Please come back later.
41
+ </div >
42
+ </template >
43
+ </ApolloQuery >
4
44
</div >
5
45
</template >
6
46
@@ -30,4 +70,18 @@ export default {
30
70
text-align : center ;
31
71
}
32
72
}
73
+
74
+ .App__article-list-item {
75
+ display : flex ;
76
+
77
+ & :not (:first-child ) {
78
+ margin-top : setting-spacing (l );
79
+ padding-top : setting-spacing (l );
80
+ border-top : 1px solid #e2e2e2 ;
81
+ }
82
+ }
83
+
84
+ .App__article-list-body {
85
+ margin-left : setting-spacing (m );
86
+ }
33
87
</style >
Original file line number Diff line number Diff line change
1
+ {
2
+ articles {
3
+ body
4
+ id
5
+ image
6
+ title
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments