Notebooks >> Scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

110 lines
2.4 KiB

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "960f7042-b00b-40b0-9d56-f4e157819dc6",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "8a83cbfd-c38b-40f5-8c24-c53dbbc6b29d",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "0019cd52-56b8-4f1d-82f5-55137f05456b",
"metadata": {},
"outputs": [],
"source": [
"pip install gql[all] aiohttp"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6658fd82-d8db-4a80-a103-3f015c851e69",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [],
"source": [
"import asyncio\n",
"\n",
"from gql import Client, gql\n",
"from gql.transport.aiohttp import AIOHTTPTransport\n",
"\n",
"transport = AIOHTTPTransport(\n",
" url=\"http://wiki:3000/graphql\",\n",
" headers={\n",
" \"Content-type\": \"application/json\",\n",
" \"Authorization\": \"os.env(directus_token)\",\n",
" },\n",
")\n",
"\n",
"client = Client(transport=transport, fetch_schema_from_transport=False)\n",
"\n",
"query = gql(\n",
" \"\"\"\n",
" query pageList {\n",
" pages {\n",
" list(locale: \"en\") {\n",
" id\n",
" path\n",
" locale\n",
" title\n",
" description\n",
" contentType\n",
" isPublished\n",
" isPrivate\n",
" privateNS\n",
" createdAt\n",
" updatedAt\n",
" tags\n",
" }\n",
" }\n",
" }\n",
"\"\"\"\n",
")\n",
"\n",
"result = await client.execute_async(query)\n",
"print(result)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}