Skip to content

Instantly share code, notes, and snippets.

@MoritzGruber
Created September 25, 2023 15:55
Show Gist options
  • Save MoritzGruber/084a0f32c6d52727d36e6c6e6c096007 to your computer and use it in GitHub Desktop.
Save MoritzGruber/084a0f32c6d52727d36e6c6e6c096007 to your computer and use it in GitHub Desktop.
python example how to query caisy with a graphql client
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport
# Select your transport with a defined url endpoint
transport = AIOHTTPTransport(url="https://cloud.caisy.io/api/v3/e/593065a4-0e27-4c4b-b1e3-25e3fd3ebfb9/graphql",
headers={'x-caisy-apikey': '2GjbTs8uQAh4IblXQs8YAYrvboKXvi54'}
)
# Create a GraphQL client using the defined transport
client = Client(transport=transport, fetch_schema_from_transport=True)
# Provide a GraphQL query
query = gql(
"""
query MyQuery {
allAsset {
edges {
node {
id
src
title
}
}
}
}
"""
)
# Execute the query on the transport
result = client.execute(query)
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment