Skip to content

Commit

Permalink
Bugfix/updated schema for search-get_article (#31)
Browse files Browse the repository at this point in the history
* fix(README): Update star history chart link in README

* feat: Add include_content parameter to get_article method

The `get_article` method in the `OmnivoreQL` class now accepts an optional `include_content` parameter. This parameter allows the user to specify whether or not to include the content of the article in the response. This change provides more flexibility and control when retrieving articles.
  • Loading branch information
yazdipour authored Jul 12, 2024
1 parent 12314a7 commit f135b32
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 52 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ If you find this project useful, you can support it by becoming a sponsor. Your
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Star History
Check out our growth in the community:

## Star History
Check out our growth in the community:

[![Star History Chart](https://api.star-history.com/svg?repos=yazdipour/OmnivoreQL&type=Date)](https://star-history.com/#yazdipour/OmnivoreQL&Date)
3 changes: 2 additions & 1 deletion omnivoreql/omnivoreql.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_articles(
},
)

def get_article(self, username: str, slug: str, format: str = None):
def get_article(self, username: str, slug: str, format: str = None, include_content: bool = False):
"""
Get an article by username and slug.
Expand All @@ -143,6 +143,7 @@ def get_article(self, username: str, slug: str, format: str = None):
"username": username,
"slug": slug,
"format": format,
"includeContent": include_content,
},
)

Expand Down
116 changes: 68 additions & 48 deletions omnivoreql/queries/Search.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,7 @@ query Search(
edges {
cursor
node {
id
title
slug
url
pageType
contentReader
createdAt
isArchived
readingProgressPercent
readingProgressTopPercent
readingProgressAnchorIndex
author
image
description
publishedAt
ownedByViewer
originalArticleUrl
uploadFileId
labels {
id
name
color
}
pageId
shortId
quote
annotation
state
siteName
subscription
readAt
savedAt
wordsCount
recommendations {
id
name
note
user {
userId
name
username
profileImageURL
}
recommendedAt
}
highlights {
...HighlightFields
}
...SearchItemFields
}
}
pageInfo {
Expand Down Expand Up @@ -102,3 +55,70 @@ fragment HighlightFields on Highlight {
createdAt
}
}
fragment SearchItemFields on SearchItem {
id
title
slug
url
pageType
contentReader
createdAt
updatedAt
isArchived
readingProgressPercent
readingProgressTopPercent
readingProgressAnchorIndex
author
image
description
publishedAt
ownedByViewer
originalArticleUrl
uploadFileId
color
labels {
id
name
color
}
pageId
shortId
quote
annotation
state
siteName
subscription
unsubMailTo
unsubHttpUrl
readAt
savedAt
wordsCount
recommendations {
id
name
note
user {
userId
name
username
profileImageURL
}
recommendedAt
}
highlights {
...HighlightFields
}
language
siteIcon
content
archivedAt
feedContent
previewContentType
links
folder
aiSummary
directionality
format
score
seenAt
}
4 changes: 3 additions & 1 deletion tests/test_omnivoreql.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ def test_save_page(self):

def test_get_articles(self):
# When
articles = self.client.get_articles()
articles = self.client.get_articles(include_content=True)
# Then
self.assertIsNotNone(articles)
self.assertNotIn("errorCodes", articles["search"])
self.assertGreater(len(articles["search"]["edges"]), 0)
self.assertIsNotNone(articles["search"]["edges"][0]["node"]["id"])
self.assertIsNotNone(articles["search"]["edges"][0]["node"]["content"])

def test_get_article(self):
# Given
Expand Down

0 comments on commit f135b32

Please sign in to comment.