await client.mutate({ mutation: UPDATE_MESSAGE_SEEN, variables: {
async deletePost(activity) { const result = await this.client.mutate({ mutation: gql` mutation { DeletePost(id: "${extractIdFromActivityId(activity.object.id)}") { title } } `, }) throwErrorIfApolloErrorOccurred(result) }
sendMachineStatus(variables: MachineStatus) { const client = new ApolloClient({ link: this.link, cache: new InMemoryCache(), }); return client.mutate({ mutation: this.machineStatusQuery.query, variables, }); }
const doUpvoted = upvotedPost => { client .mutate({ mutation: upvotedMutation, variables: { ...upvotedPost } }) .then(() => { console.log("WithStaticCache upvotedPost then"); }) .catch(err => { console.log("catch", err); }); }
const createProduct = (product) => { return client .mutate({ mutation: MUTATION_QUERY, variables: { product: { ...product, price: parseFloat(product.price)} } }) }
async updatePost(activity) { const postObject = activity.object const postId = extractIdFromActivityId(postObject.id) const date = postObject.updated ? postObject.updated : new Date().toISOString() const result = await this.client.mutate({ mutation: gql` mutation { UpdatePost(content: "${postObject.content}", contentExcerpt: "${ trunc(postObject.content, 120).html }", id: "${postId}", updatedAt: "${date}") { title } } `, }) throwErrorIfApolloErrorOccurred(result) }
client .mutate({ mutation: addPostMutationQuery, variables: { title: 'anything' }, }) .then((result) => { console.log('\n=================MUTATE') console.log(result) client .query({ query: postsQuery, }) .then((result) => { console.log('\n=================QUERY') console.log(result.data) }) })
async undoFollowActivity(fromActorId, toActorId) { const fromUserId = await this.ensureUser(fromActorId) const toUserId = await this.ensureUser(toActorId) const result = await this.client.mutate({ mutation: gql` mutation { RemoveUserFollowedBy(from: {id: "${fromUserId}"}, to: {id: "${toUserId}"}) { from { name } } } `, }) debug(`undoFollowActivity result = ${JSON.stringify(result, null, 2)}`) throwErrorIfApolloErrorOccurred(result) }
/* Performs a basic mutation */ const createList = async title => { const _res = await client.mutate({ variables: { title }, mutation: gql` mutation CreateAList($title: String!) { createList(data: { title: $title }) { title _id } } ` }); console.log(JSON.stringify(_res.data, null, 2)); }
client .mutate({ mutation: upvoteMutation, variables: { postId: post.id, inVote: newVote } }) .then(data => { const { upvotePost } = data.data; doUpvoted(upvotePost); this.getPosts(); }) .catch(err => { console.log("catch", err); });
async addSharedInboxEndpoint(uri) { try { const result = await this.client.mutate({ mutation: gql` mutation { CreateSharedInboxEndpoint(uri: "${uri}") } `, }) throwErrorIfApolloErrorOccurred(result) return true } catch (e) { return false } }
await client.mutate({ mutation: UPDATE_MESSAGE_SEEN, variables: {
sendMachineStatus(variables: MachineStatus) { const client = new ApolloClient({ link: this.link, cache: new InMemoryCache(), }); return client.mutate({ mutation: this.machineStatusQuery.query, variables, }); }