Update local school class cache after joining a class
This commit is contained in:
parent
a4a5e37268
commit
76fa510053
|
|
@ -1,5 +1,9 @@
|
|||
mutation JoinClass($input: JoinClassInput!) {
|
||||
joinClass(input: $input) {
|
||||
success
|
||||
schoolClass {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
<script>
|
||||
import JOIN_CLASS_MUTATION from '@/graphql/gql/mutations/joinClass.gql';
|
||||
import ME_QUERY from '@/graphql/gql/meQuery.gql';
|
||||
|
||||
export default {
|
||||
data: () => ({
|
||||
|
|
@ -40,6 +41,18 @@
|
|||
input: {
|
||||
code
|
||||
}
|
||||
},
|
||||
update(store, {data: {joinClass: {schoolClass}}}) {
|
||||
if (schoolClass) {
|
||||
const data = store.readQuery({query: ME_QUERY});
|
||||
if (data) {
|
||||
data.me.schoolClasses.edges.push({
|
||||
node: schoolClass,
|
||||
__typename: 'SchoolClassNode'
|
||||
});
|
||||
store.writeQuery({query: ME_QUERY, data});
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch(e => {
|
||||
console.debug(e);
|
||||
|
|
|
|||
Loading…
Reference in New Issue