GitHub Action
commited on
Commit
·
7491220
1
Parent(s):
12ac8ff
Sync from GitHub with Git LFS
Browse files
scripts/publish_to_hashnode.py
CHANGED
|
@@ -47,11 +47,14 @@ def file_hash(path):
|
|
| 47 |
|
| 48 |
|
| 49 |
def graphql_request(query, variables):
|
| 50 |
-
headers = {"Authorization": HASHNODE_TOKEN}
|
| 51 |
response = requests.post(API_URL, json={"query": query, "variables": variables}, headers=headers)
|
|
|
|
| 52 |
if response.status_code != 200:
|
| 53 |
raise Exception(f"GraphQL request failed with {response.status_code}: {response.text}")
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
def create_post(title, slug, html):
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
def graphql_request(query, variables):
|
| 50 |
+
headers = {"Authorization": f"Bearer {HASHNODE_TOKEN}"}
|
| 51 |
response = requests.post(API_URL, json={"query": query, "variables": variables}, headers=headers)
|
| 52 |
+
resp_json = response.json()
|
| 53 |
if response.status_code != 200:
|
| 54 |
raise Exception(f"GraphQL request failed with {response.status_code}: {response.text}")
|
| 55 |
+
if "errors" in resp_json:
|
| 56 |
+
raise Exception(f"GraphQL errors: {resp_json['errors']}")
|
| 57 |
+
return resp_json
|
| 58 |
|
| 59 |
|
| 60 |
def create_post(title, slug, html):
|