Skip to content

Invalid or incomplete introspection with async transport #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dysphie opened this issue Jun 6, 2020 · 4 comments · Fixed by #111
Closed

Invalid or incomplete introspection with async transport #101

dysphie opened this issue Jun 6, 2020 · 4 comments · Fixed by #111
Labels
type: bug An issue or pull request relating to a bug

Comments

@dysphie
Copy link

dysphie commented Jun 6, 2020

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

@leszekhanusz
Copy link
Collaborator

Hi,

This is a duplicate of bug #92
It is solved with PR #94

@KingDarBoja KingDarBoja added the type: bug An issue or pull request relating to a bug label Jun 15, 2020
@jsbroks
Copy link
Contributor

jsbroks commented Jul 6, 2020

@leszekhanusz I've cloned master and did 'pip3 install .', but still get

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

@jsbroks
Copy link
Contributor

jsbroks commented Jul 6, 2020

@leszekhanusz Your PR does not fix the same error when using the WebsocketsTransport transport

@megakid
Copy link

megakid commented Apr 20, 2022

Just a note to others, or maybe I was just being dumb, but I was missing a / at the end of the graphql URL:

e.g.

transport = AIOHTTPTransport(url="https://api.octopus.energy/v1/graphql/") # works

vs

transport = AIOHTTPTransport(url="https://api.octopus.energy/v1/graphql") # does not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants