getBlogByHandle method
Future<Blog>
getBlogByHandle(
- String handle, {
- SortKeyArticle sortKeyArticle = SortKeyArticle.RELEVANCE,
- bool deleteThisPartOfCache = false,
- bool reverse = false,
Returns a Blog.
Returns the Blog that is associated to the handle
.
sortKeyArticle
is meant for the List of Article in the Blog.
Implementation
Future<Blog> getBlogByHandle(String handle,
{SortKeyArticle sortKeyArticle = SortKeyArticle.RELEVANCE,
bool deleteThisPartOfCache = false,
bool reverse = false}) async {
final QueryOptions _options =
WatchQueryOptions(document: gql(getBlogByHandleQuery), variables: {
'handle': handle,
'sortKey': sortKeyArticle.parseToString(),
'reverseArticles': reverse
});
final QueryResult result = await _graphQLClient!.query(_options);
checkForError(result);
var response = result.data!['blogByHandle'];
var newResponse = {'node': response};
if (deleteThisPartOfCache) {
_graphQLClient!.cache.writeQuery(_options.asRequest, data: {});
}
return Blog.fromGraphJson(newResponse);
}