Created
December 30, 2021 11:58
-
-
Save AndrewBarfield/ee524743bdf3c2345628da0dcb937609 to your computer and use it in GitHub Desktop.
Wiki.js: Purge History via GraphQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
WikiJSGraphQLAccessToken = "replace_with_your_token" | |
WikiJSGraphQLEndpoint = f"http://192.168.xx.xx:1234/graphql" | |
# Purge history older than 2 hours | |
# See: https://en.wikipedia.org/wiki/ISO_8601#Durations | |
GraphQLPagePurgeHistoryQuery = """mutation Page { | |
pages { | |
purgeHistory(olderThan: \"PT2H\") { | |
responseResult { | |
succeeded | |
errorCode | |
slug | |
message | |
} | |
} | |
} | |
}""" | |
r = requests.post( | |
WikiJSGraphQLEndpoint, | |
json={"query": GraphQLPagePurgeHistoryQuery}, | |
headers={"Authorization": f"Bearer {WikiJSGraphQLAccessToken}"}) | |
print(json.dumps(r.json(), indent=8)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment