diff --git a/backend/api_handler.py b/backend/api_handler.py index 1e1645e9e..439551f0a 100644 --- a/backend/api_handler.py +++ b/backend/api_handler.py @@ -23,6 +23,7 @@ from dataall.base.db import get_engine from dataall.base.loader import load_modules, ImportMode +from graphql.pyutils import did_you_mean logger = logging.getLogger() logger.setLevel(os.environ.get('LOG_LEVEL', 'INFO')) @@ -32,6 +33,11 @@ for name in ['boto3', 's3transfer', 'botocore', 'boto']: logging.getLogger(name).setLevel(logging.ERROR) +ALLOW_INTROSPECTION = True if os.getenv('ALLOW_INTROSPECTION') == 'True' else False + +if not ALLOW_INTROSPECTION: + did_you_mean.__globals__['MAX_LENGTH'] = 0 + load_modules(modes={ImportMode.API}) SCHEMA = bootstrap_schema() TYPE_DEFS = gql(SCHEMA.gql(with_directives=False)) @@ -138,7 +144,9 @@ def handler(event, context): else: raise Exception(f'Could not initialize user context from event {event}') - success, response = graphql_sync(schema=executable_schema, data=query, context_value=app_context) + success, response = graphql_sync( + schema=executable_schema, data=query, context_value=app_context, introspection=ALLOW_INTROSPECTION + ) dispose_context() response = json.dumps(response) diff --git a/deploy/stacks/lambda_api.py b/deploy/stacks/lambda_api.py index 1151dd994..f3138862c 100644 --- a/deploy/stacks/lambda_api.py +++ b/deploy/stacks/lambda_api.py @@ -145,6 +145,7 @@ def __init__( 'LOG_LEVEL': log_level, 'REAUTH_TTL': str(reauth_ttl), 'ALLOWED_ORIGINS': allowed_origins, + 'ALLOW_INTROSPECTION': str(not prod_sizing), } # Check if custom domain exists and if it exists email notifications could be enabled. Create a env variable which stores the domain url. This is used for sending data.all share weblinks in the email notifications. if custom_domain and custom_domain.get('hosted_zone_name', None):