'GraphQL Request in Pytho

I don't know how to solve this problem i'm trying a long time now but i'm stuck.

I've tried different Libarys for GraphQL requests but nothing is working so thats why im searching for help.

I want to use the GraphQL request to get some details from some Axies on my wallet

it would be great if anybody can help me

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


header = {
    'User-Agent': 'My User Agent 1.0',
    'From': '[email protected]',
    'Content-Type': 'application/json'
}


transport = RequestsHTTPTransport(url="https://graphql-gateway.axieinfinity.com/graphql",headers=header, use_json= True)

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

query = gql('''
{
    GetAxieBriefList{
  axies(
    auctionType: $auctionType
    criteria: $criteria
    from: $from
    sort: $sort
    size: $size
    owner: $owner
  ) {
    total
    results {
      ...AxieBrief
      __typename
    }
    __typename
  }
}

fragment AxieBrief on Axie {
  id
  name
  stage
  class
  breedCount
  image
  title
  battleInfo {
    banned
    __typename
  }
  auction {
    currentPrice
    currentPriceUSD
    __typename
  }
  parts {
    id
    name
    class
    type
    specialGenes
    __typename
  }
  __typename
}
}

''')

variables = {
    "from": 0,
    "size": 100,
    "sort": "IdDesc",
    "auctionType": "All",
    "owner": "<my0xAdress>"
    }

response_query = client.execute(query,variables)

print(response_query)

I'm getting this error and i do not know how to make the schema correctly

    raise TypeError(
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.```


Solution 1:[1]

For newer gql versions, you should use the client as:

 with client as sess:
        response = sess.execute(query, variables)

Once you implemented this, another reason for the error can be invalid authentication headers. Recheck if you are passing all necessary headers to the transport.

You can add a print statement (or use more advanced debugging methods if you want to but simple is better) to the source to inspect the response for errors.

Path: gql/client.py

def fetch_schema(self) -> None:
        """Fetch the GraphQL schema explicitely using introspection.

        Don't use this function and instead set the fetch_schema_from_transport
        attribute to True"""
        execution_result = self.transport.execute(parse(get_introspection_query()))
        # DEBUG statement on the response requesting schema
        print(execution_result)
        self.client.introspection = execution_result.data
        self.client.schema = build_client_schema(self.client.introspection)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Patrick Mutuku