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.
86 lines
1.8 KiB
86 lines
1.8 KiB
{ |
|
"cells": [ |
|
{ |
|
"cell_type": "code", |
|
"execution_count": null, |
|
"id": "927fe89f-9660-4681-884b-f258fc669b88", |
|
"metadata": {}, |
|
"outputs": [], |
|
"source": [ |
|
"pip install gql[all] aiohttp" |
|
] |
|
}, |
|
{ |
|
"cell_type": "code", |
|
"execution_count": null, |
|
"id": "a4dc5471-3df9-4d52-865e-ca9202d472a3", |
|
"metadata": {}, |
|
"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://directus:8055/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 {\n", |
|
" pages {\n", |
|
" id\n", |
|
" }\n", |
|
" }\n", |
|
"\"\"\"\n", |
|
")\n", |
|
"\n", |
|
"result = await client.execute_async(query)\n", |
|
"print(result)" |
|
] |
|
}, |
|
{ |
|
"cell_type": "code", |
|
"execution_count": null, |
|
"id": "f9429bdb-d291-49ce-8191-9977b3624f97", |
|
"metadata": {}, |
|
"outputs": [], |
|
"source": [] |
|
} |
|
], |
|
"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.10.5" |
|
}, |
|
"widgets": { |
|
"application/vnd.jupyter.widget-state+json": { |
|
"state": {}, |
|
"version_major": 2, |
|
"version_minor": 0 |
|
} |
|
} |
|
}, |
|
"nbformat": 4, |
|
"nbformat_minor": 5 |
|
}
|
|
|