Skip to content

Invalid or incomplete introspection with async transport #101

Closed
@dysphie

Description

@dysphie

Hi, I seem to be having issues migrating from a blocking implementation to async. The migrated code raises an exception.

Original:

from os import getenv
from gql import gql, Client
from gql.transport.requests import RequestsHTTPTransport

query = gql('''
    query {
        user(username:"Test") {
            username
        }
    }
''')


if __name__ == '__main__':

    transport = RequestsHTTPTransport(
        url='http://api.aidungeon.io/graphql/',
        headers={'X-Access-Token': getenv('AIDUNGEON_TOKEN')}
    )

    client = Client(
        transport=transport,
        fetch_schema_from_transport=True,
    )

    result = client.execute(query)
    print(result)

Output:

{'user': {'username': 'Test'}}

Migrated

from os import getenv
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport
import asyncio


query = gql('''
    query {
        user(username:"Test") {
            username
        }
    }
''')

async def main():

    transport = AIOHTTPTransport(
    url='http://api.aidungeon.io/graphql/',
    headers={'X-Access-Token': getenv('AIDUNGEON_TOKEN')}
    )

    client = Client(
        transport=transport,
        fetch_schema_from_transport=True
    )

    async with client as session:
        result = await session.execute(query)
        print(result)

asyncio.run(main())

Output:

TypeError: Invalid or incomplete introspection result. Ensure that you are passing the 'data' attribute of an introspection response and no 'errors' were returned alongside: None.

Not sure how to proceed. Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugAn issue or pull request relating to a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions