Skip to content

Commit 9f23e8c

Browse files
Merge pull request #4 from mirumee/feat/ariadne-1-upgrade
Feat/ariadne 1 upgrade
2 parents 35568ca + c1dbaed commit 9f23e8c

4 files changed

Lines changed: 882 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,36 @@ For released versions, see the [Releases](https://github.com/mirumee/ariadne-lam
66

77
## Unreleased
88

9-
### 🛠️ Build System
10-
- Modernize packaging metadata and CI/release workflows
9+
### Breaking Changes
1110

11+
- **Ariadne 1.x is required.** Supported versions are `ariadne>=1.0.1,<2.0.0` (the previous upper bound was `<0.30.0`). Upgrade Ariadne in applications that depend on this package before upgrading `ariadne-lambda`.
12+
- **`GraphQLLambdaHandler` subclasses `GraphQLHandlerBase`.** Ariadne 1.0 renamed the ASGI handler base class from `GraphQLHandler` to `GraphQLHandlerBase`; this package follows that API.
13+
- **Callable `context_value` must use `(request, data)`.** The old fallback for callables that only accepted `(request)` has been removed so behavior matches `GraphQLHandlerBase.get_context_for_request` in Ariadne 1.0.
1214

15+
### Bug Fixes
16+
17+
- **Lambda function URLs:** `Request.create_from_event` accepts HTTP API v2–style events used with **Lambda function URLs** when `queryStringParameters` is missing and `body` is omitted (previously could raise or mis-handle keys).
18+
19+
### Improvements
20+
21+
- Refine request parsing and GraphQL HTTP handling (Pydantic `Request` model, handler tests, and fixtures aligned with API Gateway v2 payloads).
22+
23+
### CI/CD
24+
25+
- Run tests on **Python 3.10–3.14** in a matrix; refresh GitHub Actions (`actions/setup-python`, reusable **test** / **build** / **prepare_release** / **publish** workflows).
26+
- Replace older standalone workflows (`run_tests`, `code_quality`, `deploy`) with the modernized pipeline.
27+
28+
### Build System
29+
30+
- **Hatch** packaging, expanded `pyproject.toml` metadata, optional extras for dev/test/types, and **git-cliff** (`cliff.toml`) for release notes.
31+
- Disable coverage **`fail_under`** until the test suite is expanded (previously targeted 90%).
32+
- Add **`pip`** to the `dev` optional extra so Hatch can install into a uv-managed `.venv` when `[tool.hatch.envs.default] path = ".venv"` is set (Hatch syncs via pip).
33+
- Add **`uv.lock`** for reproducible local and CI installs.
34+
35+
### Documentation
36+
37+
- Declare support for Python 3.10–3.14 in project metadata; update README contact email.
38+
39+
### Testing
40+
41+
- Add API Gateway v2 **Lambda function URL** sample payload and tests; extend HTTP handler and schema tests alongside the refactors above.

ariadne_lambda/base.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
from inspect import isawaitable
33
from typing import Any
44

5-
from ariadne.asgi.handlers.base import GraphQLHandler
5+
from ariadne.asgi.handlers.base import GraphQLHandlerBase
66
from aws_lambda_powertools.utilities.typing import LambdaContext
77

88

9-
class GraphQLLambdaHandler(GraphQLHandler):
9+
class GraphQLLambdaHandler(GraphQLHandlerBase):
1010
@abstractmethod
1111
async def handle(self, event: dict, context: LambdaContext): # ty: ignore[invalid-method-override]
1212
"""An entrypoint for the AWS Lambda connection handler.
@@ -28,13 +28,12 @@ async def handle(self, event: dict, context: LambdaContext): # ty: ignore[inval
2828
async def get_context_for_request(
2929
self,
3030
request: Any,
31-
data: dict,
31+
data: Any,
3232
) -> Any:
3333
"""Return the context value for the request.
3434
35-
This method is called by the handler to get the context value for the
36-
request. Subclasses can override it to provide custom context value
37-
based on the request.
35+
Matches `GraphQLHandlerBase.get_context_for_request`: callable
36+
`context_value` must accept `(request, data)` (sync or async).
3837
3938
# Required arguments
4039
@@ -43,10 +42,7 @@ async def get_context_for_request(
4342
`data`: GraphQL data from connection.
4443
"""
4544
if callable(self.context_value):
46-
try:
47-
context = self.context_value(request, data) # type: ignore
48-
except TypeError: # TODO: remove in 0.20
49-
context = self.context_value(request) # type: ignore
45+
context = self.context_value(request, data)
5046

5147
if isawaitable(context):
5248
context = await context

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ classifiers = [
2525
"Topic :: Software Development :: Libraries :: Python Modules",
2626
]
2727
dependencies = [
28-
"ariadne>=0.23.0,<0.30.0",
28+
"ariadne>=1.0.1,<2.0.0",
2929
"aws-lambda-powertools>=3.0.0,<4.0.0",
3030
"pydantic>=2.4.0,<3.0.0",
3131
]
3232

3333
[project.optional-dependencies]
34-
dev = ["ipdb"]
34+
# `pip` is required in `.venv` when using Hatch with `path = ".venv"` (Hatch syncs via pip).
35+
dev = ["ipdb", "pip>=24.0"]
3536
test = [
3637
"pytest>=9.0.0,<10.0.0",
3738
"pytest-asyncio>=1.0.0,<2.0.0",

0 commit comments

Comments
 (0)