Provide a draft for the edges/nodes removal

This commit is contained in:
Pawel Kowalski 2018-08-17 02:28:42 +02:00
parent 92a6e1f10f
commit 17b0047b32
2 changed files with 49 additions and 2 deletions

View File

@ -15,9 +15,32 @@ const httpLink = new HttpLink({
const consoleLink = new ApolloLink((operation, forward) => {
console.log(`starting request for ${operation.operationName}`);
// This is a proposal for our edges/nodes removal: plz review
//
// function getRidOfEdges(collection) {
// if (typeof collection === 'object') {
// let newObj = {}
// for (const k in collection) {
// if (k === 'edges' || k === 'node') {
// newObj = getRidOfEdges(collection[k])
// } else {
// newObj[k] = getRidOfEdges(collection[k])
// }
// }
// return newObj
// } else {
// return collection
// }
// }
return forward(operation).map((data) => {
console.log(`ending request for ${operation.operationName}`);
return data;
// debugger
// let data = getRidOfEdges(inData)
// return resultData;
return data
})
})

View File

@ -19,7 +19,31 @@
},
fetchPolicy: 'network-only',
manual: true,
result({data, loading}, networkStatus) {
result({data, loading, networkStatus}) {
// This is a proposal for our edges/nodes removal: plz review
//
function getRidOfEdges(collection) {
if (typeof collection === 'object') {
let newObj = {}
for (const k in collection) {
if (k === 'edges' || k === 'node') {
newObj = getRidOfEdges(collection[k])
} else {
newObj[k] = getRidOfEdges(collection[k])
}
}
return newObj
} else {
return collection
}
}
// Result of edges/nodes removal
//
var purgedData = getRidOfEdges(data)
// debugger
if (!loading) {
const node = data.modules.edges[0].node;
this.module = {