Skip to content
This repository was archived by the owner on Feb 22, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion omnivoreql/omnivoreql.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import uuid
import shortuuid
import os
from typing import List, Optional
from typing import List, Optional, Literal
from gql.transport.requests import RequestsHTTPTransport
from gql import gql, Client
from dataclasses import asdict
Expand Down Expand Up @@ -279,3 +280,24 @@ def set_page_labels_by_ids(self, page_id: str, label_ids: List[str]) -> dict:
}
},
)
def create_highlight(self, article_id: str, annotation: str,
highlight_type: Literal["HIGHLIGHT", "NOTE"]):
"""
Create a new highlight.

:param article_id: The ID of the article to create the highlight for.
:param annotation: The annotation of the highlight.
:param highlight_type: The type of the highlight.
"""
return self.client.execute(
self._get_query("CreateHighlight"),
variable_values={
"input": {
"annotation": annotation,
"articleId": article_id,
"id": str(uuid.uuid4()),
"shortId": str(shortuuid.ShortUUID().random(length=8)),
"type": highlight_type
}
},
)
24 changes: 24 additions & 0 deletions omnivoreql/queries/CreateHighlight.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,27 @@ mutation CreateHighlight($input: CreateHighlightInput!) {
}
}
}

fragment HighlightFields on Highlight {
id
type
shortId
quote
prefix
suffix
patch
color
annotation
createdByMe
createdAt
updatedAt
sharedAt
highlightPositionPercent
highlightPositionAnchorIndex
labels {
id
name
color
createdAt
}
}