feat: add app connections w/ testing and deleting functions

This commit is contained in:
Ali BARIN
2021-10-18 23:58:40 +02:00
parent 672cc4c60c
commit 2293c939e7
27 changed files with 349 additions and 34 deletions

View File

@@ -4,6 +4,31 @@ const cache = new InMemoryCache({
typePolicies: {
App: {
keyFields: ['key']
},
Mutation: {
mutationType: true,
fields: {
createConnection: {
merge(existing, newConnection, { args, readField, cache }) {
const appKey = readField('key', newConnection);
const appCacheId = cache.identify({
__typename: 'App',
key: appKey,
});
cache.modify({
id: appCacheId,
fields: {
connections: (existingConnections) => {
return [...existingConnections, newConnection];
}
}
});
return newConnection;
}
}
}
}
}
});