From 0941dc2aeb9c61db443039f9433f9983a2037b0f Mon Sep 17 00:00:00 2001 From: Noah Paige Date: Tue, 19 Nov 2024 10:53:26 -0500 Subject: [PATCH 1/2] Disable introspection on prod sizing --- backend/api_handler.py | 10 +++++++++- deploy/stacks/lambda_api.py | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/api_handler.py b/backend/api_handler.py index 1e1645e9e..ba6d560dd 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) +SCHEMA_EXPLORATION = True if os.getenv('SCHEMA_EXPLORATION') == 'True' else False + +if SCHEMA_EXPLORATION: + 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=SCHEMA_EXPLORATION + ) dispose_context() response = json.dumps(response) diff --git a/deploy/stacks/lambda_api.py b/deploy/stacks/lambda_api.py index 1151dd994..6411d7af2 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, + 'SCHEMA_EXPLORATION': str(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): From 1270abef4b2ca4d72e24ab19dde53af5281c3df3 Mon Sep 17 00:00:00 2001 From: Noah Paige Date: Tue, 19 Nov 2024 11:49:55 -0500 Subject: [PATCH 2/2] Fix env var conditions --- backend/api_handler.py | 6 +++--- deploy/stacks/lambda_api.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/api_handler.py b/backend/api_handler.py index ba6d560dd..439551f0a 100644 --- a/backend/api_handler.py +++ b/backend/api_handler.py @@ -33,9 +33,9 @@ for name in ['boto3', 's3transfer', 'botocore', 'boto']: logging.getLogger(name).setLevel(logging.ERROR) -SCHEMA_EXPLORATION = True if os.getenv('SCHEMA_EXPLORATION') == 'True' else False +ALLOW_INTROSPECTION = True if os.getenv('ALLOW_INTROSPECTION') == 'True' else False -if SCHEMA_EXPLORATION: +if not ALLOW_INTROSPECTION: did_you_mean.__globals__['MAX_LENGTH'] = 0 load_modules(modes={ImportMode.API}) @@ -145,7 +145,7 @@ def handler(event, context): raise Exception(f'Could not initialize user context from event {event}') success, response = graphql_sync( - schema=executable_schema, data=query, context_value=app_context, introspection=SCHEMA_EXPLORATION + schema=executable_schema, data=query, context_value=app_context, introspection=ALLOW_INTROSPECTION ) dispose_context() diff --git a/deploy/stacks/lambda_api.py b/deploy/stacks/lambda_api.py index 6411d7af2..f3138862c 100644 --- a/deploy/stacks/lambda_api.py +++ b/deploy/stacks/lambda_api.py @@ -145,7 +145,7 @@ def __init__( 'LOG_LEVEL': log_level, 'REAUTH_TTL': str(reauth_ttl), 'ALLOWED_ORIGINS': allowed_origins, - 'SCHEMA_EXPLORATION': str(prod_sizing), + '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):