diff --git a/datasette_graphql/__init__.py b/datasette_graphql/__init__.py index d02262f..ac18ce6 100644 --- a/datasette_graphql/__init__.py +++ b/datasette_graphql/__init__.py @@ -113,6 +113,7 @@ async def view_graphql(request, datasette): "num_queries_executed": 0, "num_queries_limit": config.get("num_queries_limit") or DEFAULT_NUM_QUERIES_LIMIT, + "request": request, # For authentication headers } result = await schema.execute_async( diff --git a/datasette_graphql/utils.py b/datasette_graphql/utils.py index 9eeb358..c346ded 100644 --- a/datasette_graphql/utils.py +++ b/datasette_graphql/utils.py @@ -594,7 +594,15 @@ async def resolve_table( path_with_query_string, ) - data = (await datasette.client.get(path_with_query_string)).json() + headers = context["request"].headers + cookies = context["request"].cookies + + response = await datasette.client.get( + path_with_query_string, headers=headers, cookies=cookies + ) + if response.status_code != 200: + raise Exception(str(response.status_code) + response.text) + data = response.json() # If any cells are $base64, decode them into bytes objects for row in data["rows"]: for key, value in row.items():