Skip to main content

Update Documents

Updating General Documents

info

Every request that updates the document itself, like meta information and the file itself, will create a new revision. While moving the memo to another folder will not.

There are not many attributes you can change on a document. Generally, you can only update the description, labels, and the extraUrl on all Documents.

mutation updateDocument($id: String!, $description: String, $labels: [String]) {
updateDocument(
input: { id: $id, description: $description, labels: $labels }
) {
document {
id
description
labels
}
}
}
// variables
{
"id": "...",
"description": "...",
"labels": ["...", "..."]
}

Update Text Documents

mutation updateTextContentOnDocument(
$id: String!
$textContent: String!
$bgcolor: String
) {
updateTextContentOnDocument(
id: $id
textContent: $textContent
backgroundColor: $bgcolor
) {
id
textContent
textContentBackground
}
}
// variables
{
"id": "...",
"textContent": "...",
"bgcolor": "#ffffff"
}

Update File Documents

Depending on the file type, there might be between 0 and 2 options to update the file. For PDF documents and images, there is the option to save annotations via an XFDF string on them.

note

Usually, images do not have XFDF, but to simplify the toolchain on all sides, we can also use pdf annotation features here.

mutation updateDocumentDrawing($documentId: String!, $xfdf: String!) {
updateDocumentDrawing(input: { documentId: $documentId, xfdf: $xfdf }) {
document {
id
downloadUrl
}
}
}
// variables
{
"documentId": "...",
"xfdf": "..."
}

And for PDF, word, and excel files, you can upload a new version. While it has "replace" in its name, it does create a new revision with the new file.

If set, the isExternalFile parameter will mark in the revision that this is a new file and is not based on the file already hosted on MemoMeister. An example use case to set it on false is if you download a pdf, make a change that is not reflected in the XFDF, and then upload that pdf again.

mutation replaceFileOnDocument($file: Upload!, $documentId: String!) {
replaceFileOnDocument(id: $documentId, file: $file, isExternalFile: true) {
id
downloadUrl
fileName
pdfPreviewUrl
printableUrl
lastModified
fileType
}
}

Rotate Images

Sometimes you need to rotate an image, too, if we didn't detect the rotation already. The deg parameter can be positive or negative and should be a multiple of 90. so 0, 90, 180, 270, 360, ...

mutation rotateDocumentImage($documentId: String!, $deg: Int!) {
rotateDocumentImage(input: { documentId: $documentId, deg: $deg }) {
document {
id
downloadUrl
}
}
}
// variables
{
"documentId": "...",
"deg": 90
}

Moving a Document to a folder

There are two options for moving a document into another folder. Either move just a single one.

mutation moveDocumentToFolder($documentId: String!, $folderId: String!) {
moveDocumentToFolder(input: { id: $documentId, folderId: $folderId }) {
document {
id
folder {
id
name
}
}
}
}
// variables
{
"documentId": "...",
"folderId": "..."
}

Or to move a lot of documents at once.

mutation moveDocumentsToFolder($ids: [String]!, $folderId: String!) {
moveDocumentsToFolder(input: { ids: $ids, folderId: $folderId }) {
userErrors {
id
message
}
}
}
// variables
{
"ids": ["...", "..."],
"folderId": "..."
}

The benefit of the first one is that you can get the document and its newly assigned folder within the same request. In most cases, the second option is the better one, as long as you do not need the document information back.

Moving Documents to the bin

This mutation is the same for moving folders into the bin. It takes a list of document and folder IDs to be moved.

mutation moveItemsToBin($ids: [String]!) {
moveItemsToBin(ids: $ids) {
success
}
}
// variables
{
"ids": ["...", "..."]
}