Replace specific edge/node removal with a generic solution: move into globally available function.
- Why is it not possible to change data with apollo link?
This commit is contained in:
parent
17b0047b32
commit
ea073a29ac
|
|
@ -8,7 +8,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>Lernziele</h3>
|
<h3>Lernziele</h3>
|
||||||
<objective-group v-for="group in module.objectiveGroups" :key="group.id" :group="group"></objective-group>
|
<objective-group v-for="group in module.objectivegroupSet" :key="group.id" :group="group"></objective-group>
|
||||||
|
|
||||||
<chapter :chapter="chapter" v-for="chapter in module.chapters" :key="chapter.id"></chapter>
|
<chapter :chapter="chapter" v-for="chapter in module.chapters" :key="chapter.id"></chapter>
|
||||||
<h3>1.1 Lehrbeginn</h3>
|
<h3>1.1 Lehrbeginn</h3>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<h4>{{group.title}}</h4>
|
<h4>{{group.title}}</h4>
|
||||||
|
|
||||||
<ul class="objective-group__objective-list">
|
<ul class="objective-group__objective-list">
|
||||||
<li class="objective-group__objective" v-for="objective in group.objectives" :key="objective.id">
|
<li class="objective-group__objective" v-for="objective in group.objectiveSet" :key="objective.id">
|
||||||
{{objective.text}}
|
{{objective.text}}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,21 @@ const httpLink = new HttpLink({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const purgeEdgesNodes = new ApolloLink((operation, forward) => {
|
||||||
|
return forward(operation).map(response => {
|
||||||
|
// if (response.data.user.lastLoginDate) {
|
||||||
|
// response.data.user.lastLoginDate = new Date(
|
||||||
|
// response.data.user.lastLoginDate
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// data.data.modules = ['is_me']
|
||||||
|
// response.data.modules = ['is_me']
|
||||||
|
// debugger
|
||||||
|
|
||||||
|
return response;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const consoleLink = new ApolloLink((operation, forward) => {
|
const consoleLink = new ApolloLink((operation, forward) => {
|
||||||
console.log(`starting request for ${operation.operationName}`);
|
console.log(`starting request for ${operation.operationName}`);
|
||||||
|
|
||||||
|
|
@ -37,14 +52,16 @@ const consoleLink = new ApolloLink((operation, forward) => {
|
||||||
return forward(operation).map((data) => {
|
return forward(operation).map((data) => {
|
||||||
console.log(`ending request for ${operation.operationName}`);
|
console.log(`ending request for ${operation.operationName}`);
|
||||||
|
|
||||||
|
// data.data.modules = ['is_me']
|
||||||
// debugger
|
// debugger
|
||||||
// let data = getRidOfEdges(inData)
|
// let data = getRidOfEdges(inData)
|
||||||
// return resultData;
|
// return resultData;
|
||||||
|
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const composedLink = ApolloLink.from([consoleLink, httpLink]);
|
const composedLink = ApolloLink.from([purgeEdgesNodes, consoleLink, httpLink]);
|
||||||
|
|
||||||
// Create the apollo client
|
// Create the apollo client
|
||||||
export default new ApolloClient({
|
export default new ApolloClient({
|
||||||
|
|
|
||||||
|
|
@ -39,29 +39,31 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result of edges/nodes removal
|
|
||||||
//
|
|
||||||
var purgedData = getRidOfEdges(data)
|
|
||||||
// debugger
|
|
||||||
|
|
||||||
if (!loading) {
|
if (!loading) {
|
||||||
const node = data.modules.edges[0].node;
|
// Result of edges/nodes removal
|
||||||
this.module = {
|
//
|
||||||
...node,
|
const purgedData = getRidOfEdges(data)
|
||||||
objectiveGroups: mapNodes(node.objectivegroupSet, node => {
|
this.module = purgedData.modules[0]
|
||||||
return {
|
|
||||||
...node,
|
|
||||||
objectives: mapNodes(node.objectiveSet, node => node)
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
chapters: mapNodes(node.chapters, node => {
|
|
||||||
return {
|
|
||||||
...node,
|
|
||||||
contentBlocks: mapNodes(node.contentBlocks, node => node)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (!loading) {
|
||||||
|
// const node = data.modules.edges[0].node;
|
||||||
|
// this.module = {
|
||||||
|
// ...node,
|
||||||
|
// objectiveGroups: mapNodes(node.objectivegroupSet, node => {
|
||||||
|
// return {
|
||||||
|
// ...node,
|
||||||
|
// objectives: mapNodes(node.objectiveSet, node => node)
|
||||||
|
// };
|
||||||
|
// }),
|
||||||
|
// chapters: mapNodes(node.chapters, node => {
|
||||||
|
// return {
|
||||||
|
// ...node,
|
||||||
|
// contentBlocks: mapNodes(node.contentBlocks, node => node)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// };
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue