Is your feature request related to a problem? Please describe.
Owing to I need cache, so use addTypename: false is not my solution
vue apollo have provide some way to remove __typename when mutation?
Describe the solution you'd like
Add some middleware to handle this problem by vue-apollo integration or add some code to remove __typename when mutation
Describe alternatives you've considered
just delete __typename when mutation
I think it's not a good idea
Hi, I'm having the same issues as @AruXc. I totally agreed this should be handled by apollo client or vue-apollo. There's already an issue on Apollo repository. here.
for someone need the solution
these base on @jdinartejesus mentioned issue.
import { getMainDefinition } from "apollo-utilities"
import omitDeep from 'omit-deep-lodash'
...
const cleanTypenameLink = new ApolloLink((operation, forward) => {
// more keys like timestamps could be included here
const keysToOmit = ['__typename']
const def = getMainDefinition(operation.query)
if (def && def.operation === 'mutation') {
operation.variables = omitDeep(operation.variables, keysToOmit)
}
return forward ? forward(operation) : null
})
...
// Create the apollo client
const apolloClient = new ApolloClient({
link: ApolloLink.from([cleanTypenameLink, authLink, httpLink]),
cache
})
It's definitely a good temporary solution, but I believe should be solved internally on Apollo Client or Vue-Apollo.
There are a few other solutions exists: https://stackoverflow.com/questions/47211778/cleaning-unwanted-fields-from-graphql-responses/51380645#51380645
But in that case apollo-client will not be able resolve and update a cache of the fragments.