File tree 3 files changed +39
-19
lines changed
3 files changed +39
-19
lines changed Original file line number Diff line number Diff line change 43
43
}
44
44
}
45
45
`
46
+ const FEED_QUERY = gql `
47
+ query feed {
48
+ feed {
49
+ id
50
+ text
51
+ title
52
+ isPublished
53
+ }
54
+ }
55
+ `
56
+
46
57
export default {
47
58
data : () => ({
48
59
title: ' ' ,
49
60
text: ' '
50
61
}),
51
-
62
+
52
63
// Attribute
53
64
methods: {
54
65
create () {
55
66
const title = this .title
56
67
const text = this .text
57
-
68
+
58
69
this .title = ' '
59
70
this .text = ' '
60
-
71
+
61
72
// Mutation
62
73
this .$apollo .mutate ({
63
74
mutation: CREATE_POST ,
64
75
variables: {
65
76
title,
66
77
text,
67
78
},
79
+ // Update the cache with the result
80
+ // and then with the real result of the mutation
81
+ update : (store , { data: { createDraft } }) => {
82
+ // Read the data from our cache for this query.
83
+ const data = store .readQuery ({ query: FEED_QUERY })
84
+ // Add our post from the mutation to the end
85
+ data .tags .push (createDraft)
86
+ // Write our data back to the cache.
87
+ store .writeQuery ({ query: FEED_QUERY , data })
88
+ }
68
89
}).then ((data ) => {
69
90
// Result
70
91
console .log (data);
71
- router .push ({ path: ' Drafts' })
92
+ this . $ router .push ({ path: ' Drafts' })
72
93
}).catch ((error ) => {
73
94
// Error
74
95
alert (` Error from ${ error} ` )
102
123
margin-top : 35px ;
103
124
float : left ;
104
125
}
105
-
126
+
106
127
.createPost :hover {
107
128
box-shadow : 0 8px 16px 0 rgba (0 , 0 , 0 , 0.2 );
108
129
}
109
-
130
+
110
131
.newPost {
111
132
border : none ;
112
133
color : gray ;
113
134
background-color : white ;
114
135
}
115
-
136
+
116
137
.plusImage {
117
138
opacity : 0.4 ;
118
139
margin-top : 25% ;
119
140
width : 25% ;
120
141
height : 25% ;
121
142
}
122
-
143
+
123
144
.modal-mask {
124
145
position : fixed ;
125
146
z-index : 9998 ;
179
200
justify-content: flex-start;
180
201
flex-direction: column;
181
202
}*/
182
- </style >
203
+ </style >
Original file line number Diff line number Diff line change 60
60
post: {},
61
61
loading: 0 ,
62
62
}),
63
-
63
+
64
64
// Apollo GraphQL
65
65
apollo: {
66
66
post: {
73
73
}
74
74
},
75
75
},
76
-
76
+
77
77
// Attribute
78
78
methods: {
79
79
deletePost () {
86
86
}).then ((data ) => {
87
87
// Result
88
88
console .log (data);
89
- router .push ({ path: ' Feed' })
89
+ this . $ router .push ({ path: ' Feed' })
90
90
}).catch ((error ) => {
91
91
// Error
92
92
console .error (error)
93
93
})
94
94
},
95
95
publishDraft () {
96
96
const postId = this .$route .params .id
97
-
98
97
// Mutation
99
98
this .$apollo .mutate ({
100
99
mutation: PUBLISH_MUTATION ,
104
103
}).then ((data ) => {
105
104
// Result
106
105
console .log (data);
107
- router .push ({ path: ' Drafts' })
106
+ this . $ router .push ({ path: ' Drafts' })
108
107
}).catch ((error ) => {
109
108
// Error
110
109
console .error (error)
124
123
margin-top : 35px ;
125
124
float : left ;
126
125
}
127
-
126
+
128
127
.createPost :hover {
129
128
box-shadow : 0 8px 16px 0 rgba (0 , 0 , 0 , 0.2 );
130
129
}
131
-
130
+
132
131
.newPost {
133
132
border : none ;
134
133
color : gray ;
135
134
background-color : white ;
136
135
}
137
-
136
+
138
137
.plusImage {
139
138
opacity : 0.4 ;
140
139
margin-top : 25% ;
141
140
width : 25% ;
142
141
height : 25% ;
143
142
}
144
-
143
+
145
144
.modal-mask {
146
145
position : fixed ;
147
146
z-index : 9998 ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import ApolloClient, { createNetworkInterface } from 'apollo-client'
4
4
import VueApollo from 'vue-apollo'
5
5
import router from './router'
6
6
7
- const networkInterface = createNetworkInterface ( { uri : 'http ://localhost:4000 ' } ) ;
7
+ const networkInterface = createNetworkInterface ( { uri : 'https ://uniserver.now.sh/ ' } ) ;
8
8
9
9
const apolloClient = new ApolloClient ( {
10
10
networkInterface,
You can’t perform that action at this time.
0 commit comments