Invalid or incomplete introspection result
Closed this issue · 4 comments
Describe the bug
Since I upgraded from 2.0.0 to 3.2.0 (I also tested 3.1.0, same problem) I've been getting this error
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.
To Reproduce
I've installed the gql[requests]
package, as instructed in the docs #327 (comment)
This code runs on an AWS Lambda
Here is how I create the gql client
import json
from boto3 import Session as AWSSession
from requests_aws4auth import AWS4Auth
from gql import gql
from gql.client import Client
from gql.transport.requests import RequestsHTTPTransport
from requests.auth import AuthBase
def _create_gql_client():
aws_session = AWSSession()
gql_api_endpoint="XXX"
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
credentials = aws_session.get_credentials().get_frozen_credentials()
auth = AWS4Auth(
credentials.access_key,
credentials.secret_key,
aws_session.region_name,
'appsync',
session_token=credentials.token,
)
transport = RequestsHTTPTransport(
url=gql_api_endpoint,
headers=headers,
auth=auth
)
return Client(
transport=transport,
fetch_schema_from_transport=True
)
I get the error when trying to perform a mutation with gql_client.execute(...)
Expected behavior
The mutation should work as it has been working for the last year. I've actually tested with 2.0.0 and I get no issues.
System info (please complete the following information):
- OS: AWS Lambda
- Python version: 3.8
- gql version: 3.2.0 (also 3.1.0)
- graphql-core version: not sure, we are using AppSync
On the 2.x versions, if there was an error when fetching the schema from the backend, this error was silently discarded.
This is no more the case in the 3.x versions.
Could you please:
- activate DEBUG logs and sent it here so that we can see the answer of the backend
- try with
fetch_schema_from_transport=False
which does not try to get the schema
With the debug logs I get from gql
:
{
"query": "query IntrospectionQuery {\n __schema {\n queryType {\n name\n }\n mutationType {\n name\n }\n subscriptionType {\n name\n }\n types {\n ...FullType\n }\n directives {\n name\n description\n locations\n args {\n ...InputValue\n }\n }\n }\n}\n\nfragment FullType on __Type {\n kind\n name\n description\n fields(includeDeprecated: true) {\n name\n description\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n description\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n}\n\nfragment InputValue on __InputValue {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n}\n\nfragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n}"
}
Then the errors:
{
"errors": [
{
"errorType": "UnauthorizedException",
"message": "Permission denied"
}
]
}
Is it possible that gql
uses the keyword kind
on some meta-programming? We have a field named like that.
Also disabling the schema fetch fixes the issue. Do we need it for anything? We are just using this library to run queries and mutations (hardcoded, we don't create them based on schema information or anything)
Is it possible that
gql
uses the keywordkind
on some meta-programming? We have a field named like that.
We are using a classic introspection query, it has nothing to do with your schema, you can use kind
without problem.
Also disabling the schema fetch fixes the issue. Do we need it for anything? We are just using this library to run queries and mutations (hardcoded, we don't create them based on schema information or anything)
Not really. If the schema is available, then gql will verify the queries locally before sending them to the backend but it also works correctly without a schema.