Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for extensions to the HTTP protocol #3461

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions strawberry/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class GraphQLRequestData:
query: Optional[str]
variables: Optional[Dict[str, Any]]
operation_name: Optional[str]
extensions: Optional[Dict[str, Any]]


def parse_query_params(params: Dict[str, str]) -> Dict[str, Any]:
Expand All @@ -47,4 +48,5 @@ def parse_request_data(data: Mapping[str, Any]) -> GraphQLRequestData:
query=data.get("query"),
variables=data.get("variables"),
operation_name=data.get("operationName"),
extensions=data.get("extensions"),
)
1 change: 1 addition & 0 deletions strawberry/http/async_base_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ async def execute_operation(
context_value=context,
operation_name=request_data.operation_name,
allowed_operation_types=allowed_operation_types,
protocol_extensions=request_data.extensions
)

async def parse_multipart(self, request: AsyncHTTPRequestAdapter) -> Dict[str, str]:
Expand Down
1 change: 1 addition & 0 deletions strawberry/schema/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async def execute(
root_value: Optional[Any] = None,
operation_name: Optional[str] = None,
allowed_operation_types: Optional[Iterable[OperationType]] = None,
protocol_extensions: Optional[Dict[str, Any]] = None,
) -> ExecutionResult:
raise NotImplementedError

Expand Down
4 changes: 4 additions & 0 deletions strawberry/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ async def execute(
root_value: Optional[Any] = None,
operation_name: Optional[str] = None,
allowed_operation_types: Optional[Iterable[OperationType]] = None,
protocol_extensions: Optional[Dict[str, Any]] = None,
) -> ExecutionResult:
if allowed_operation_types is None:
allowed_operation_types = DEFAULT_ALLOWED_OPERATION_TYPES
Expand All @@ -258,6 +259,7 @@ async def execute(
root_value=root_value,
variables=variable_values,
provided_operation_name=operation_name,
protocol_extensions=protocol_extensions
)

result = await execute(
Expand All @@ -279,6 +281,7 @@ def execute_sync(
root_value: Optional[Any] = None,
operation_name: Optional[str] = None,
allowed_operation_types: Optional[Iterable[OperationType]] = None,
protocol_extensions: Optional[Dict[str, Any]] = None,
) -> ExecutionResult:
if allowed_operation_types is None:
allowed_operation_types = DEFAULT_ALLOWED_OPERATION_TYPES
Expand All @@ -290,6 +293,7 @@ def execute_sync(
root_value=root_value,
variables=variable_values,
provided_operation_name=operation_name,
protocol_extensions=protocol_extensions
)

result = execute_sync(
Expand Down
1 change: 1 addition & 0 deletions strawberry/types/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ExecutionContext:
schema: Schema
context: Any = None
variables: Optional[Dict[str, Any]] = None
protocol_extensions: Optional[Dict[str, Any]] = None
parse_options: ParseOptions = dataclasses.field(
default_factory=lambda: ParseOptions()
)
Expand Down
Loading