diff --git a/src/graphql.tsx b/src/graphql.tsx index cc6c1997e0..ca5f958794 100644 --- a/src/graphql.tsx +++ b/src/graphql.tsx @@ -213,6 +213,7 @@ export default function graphql { - const opts = this.calculateOptions(this.props, mutationOpts); + dataForChildViaMutation(mutationOpts: MutationOpts) { + const opts = this.calculateOptions(this.props, mutationOpts); + + if (typeof opts.variables === 'undefined') delete opts.variables; - if (typeof opts.variables === 'undefined') delete opts.variables; + (opts as any).mutation = document; + return this.client.mutate((opts as any)); + } - (opts as any).mutation = document; - return this.client.mutate((opts as any)); - }; + dataForChild() { + if (this.type === DocumentType.Mutation) { + return this.dataForChildViaMutation; } const opts = this.calculateOptions(this.props);