Skip to content

Commit

Permalink
Ariadne 0.23
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp committed Mar 18, 2024
1 parent a6175b8 commit 2c9d2d4
Show file tree
Hide file tree
Showing 13 changed files with 6,727 additions and 3 deletions.
8 changes: 8 additions & 0 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,7 @@ async def graphql(
introspection: bool,
logger: Union[None, str, Logger, LoggerAdapter],
validation_rules: Optional[ValidationRules],
require_query: bool,
error_formatter: ErrorFormatter,
middleware: MiddlewareList,
middleware_manager_class: Optional[Type[MiddlewareManager]],
Expand Down Expand Up @@ -2758,6 +2759,9 @@ errors.
`validation_rules`: a `list` of or callable returning list of custom
validation rules to use to validate query before it's executed.

`require_query`: a `bool` controlling if GraphQL operation to execute must be
a query (vs. mutation or subscription).

`error_formatter`: an [`ErrorFormatter`](types-reference.md#errorformatter) callable to use to convert GraphQL
errors encountered during query execution to JSON-serializable format.

Expand Down Expand Up @@ -2796,6 +2800,7 @@ def graphql_sync(
introspection: bool,
logger: Union[None, str, Logger, LoggerAdapter],
validation_rules: Optional[ValidationRules],
require_query: bool,
error_formatter: ErrorFormatter,
middleware: MiddlewareList,
middleware_manager_class: Optional[Type[MiddlewareManager]],
Expand Down Expand Up @@ -2853,6 +2858,9 @@ errors.
`validation_rules`: a `list` of or callable returning list of custom
validation rules to use to validate query before it's executed.

`require_query`: a `bool` controlling if GraphQL operation to execute must be
a query (vs. mutation or subscription).

`error_formatter`: an [`ErrorFormatter`](types-reference.md#errorformatter) callable to use to convert GraphQL
errors encountered during query execution to JSON-serializable format.

Expand Down
25 changes: 23 additions & 2 deletions docs/asgi-handlers-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Returns a `dict` with GraphQL query data that was not yet validated.
#### `extract_data_from_json_request`

```python
async def extract_data_from_json_request(self, request: Request) -> None:
async def extract_data_from_json_request(self, request: Request) -> dict:
...
```

Expand All @@ -198,7 +198,10 @@ Returns a `dict` with GraphQL query data that was not yet validated.
#### `extract_data_from_multipart_request`

```python
async def extract_data_from_multipart_request(self, request: Request) -> None:
async def extract_data_from_multipart_request(
self,
request: Request,
) -> Union[dict, list]:
...
```

Expand All @@ -212,6 +215,23 @@ Returns an unvalidated `dict` with GraphQL query data.
`request`: the `Request` instance from Starlette or FastAPI.


#### `extract_data_from_get_request`

```python
def extract_data_from_get_request(self, request: Request) -> dict:
...
```

Extracts GraphQL data from GET request's querystring.

Returns a `dict` with GraphQL query data that was not yet validated.


##### Required arguments

`request`: the `Request` instance from Starlette or FastAPI.


#### `execute_graphql_query`

```python
Expand Down Expand Up @@ -406,6 +426,7 @@ def configure(
query_parser: Optional[QueryParser] = None,
query_validator: Optional[QueryValidator] = None,
validation_rules: Optional[ValidationRules] = None,
execute_get_queries: bool = False,
debug: bool = False,
introspection: bool = True,
explorer: Optional[Explorer] = None,
Expand Down
4 changes: 4 additions & 0 deletions docs/asgi-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
query_parser: Optional[QueryParser],
query_validator: Optional[QueryValidator],
validation_rules: Optional[ValidationRules],
execute_get_queries: bool,
debug: bool,
introspection: bool,
explorer: Optional[Explorer],
Expand Down Expand Up @@ -71,6 +72,9 @@ Defaults to `None`.
list of extra validation rules server should use to validate the
GraphQL queries. Defaults to `None`.

`execute_get_queries`: a `bool` that controls if `query` operations
sent using the `GET` method should be executed. Defaults to `False`.

`debug`: a `bool` controlling in server should run in debug mode or
not. Controls details included in error data returned to clients.
Defaults to `False`.
Expand Down
45 changes: 45 additions & 0 deletions docs/types-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,51 @@ Many parts of its API share or rely on common types, importable from `ariadne.ty



## `BaseProxyRootValue`

```python
class BaseProxyRootValue:
...
```

A [`RootValue`](types-reference.md#rootvalue) wrapper that includes result JSON update logic.

Can be returned by the [`RootValue`](types-reference.md#rootvalue) callable. Not used by Ariadne directly
but part of the support for Ariadne GraphQL Proxy.


### Attributes

- `root_value: Optional[dict]`: [`RootValue`](types-reference.md#rootvalue) to use during query execution.


### Constructor

```python
def __init__(self, root_value: Optional[dict] = None):
...
```


### Methods

#### `update_result`

```python
def update_result(self, result: GraphQLResult) -> GraphQLResult:
...
```

An update function used to create a final `GraphQL` result tuple to
create a JSON response from.

Default implementation in `BaseProxyRootValue` is a passthrough that
returns `result` value without any changes.


- - - - -


## `ContextValue`

```python
Expand Down
55 changes: 54 additions & 1 deletion docs/wsgi-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
explorer: Optional[Explorer],
logger: Optional[str],
error_formatter: ErrorFormatter,
execute_get_queries: bool,
extensions: Optional[Extensions],
middleware: Optional[Middlewares],
middleware_manager_class: Optional[Type[MiddlewareManager]],
Expand Down Expand Up @@ -90,6 +91,9 @@ instance should use for logging errors. If not set, a logger named
GraphQL errors returned to clients. If not set, default formatter
implemented by Ariadne is used.

`execute_get_queries`: a `bool` that controls if `query` operations
sent using the `GET` method should be executed. Defaults to `False`.

[`extensions`](types-reference.md#extensions): an [`Extensions`](types-reference.md#extensions) list or callable returning a
list of extensions server should use during query execution. Defaults
to no extensions.
Expand Down Expand Up @@ -211,7 +215,56 @@ def handle_get(self, environ: dict, start_response) -> List[bytes]:
...
```

Handles WSGI HTTP GET request and returns a a response to the client.
Handles WSGI HTTP GET request and returns a response to the client.

Returns list of bytes with response body.


##### Required arguments

`environ`: a WSGI environment dictionary.

`start_response`: a callable used to begin new HTTP response.


#### `handle_get_query`

```python
def handle_get_query(
self,
environ: dict,
start_response,
query_params: dict,
) -> List[bytes]:
...
```


#### `extract_data_from_get`

```python
def extract_data_from_get(self, query_params: dict) -> dict:
...
```

Extracts GraphQL data from GET request's querystring.

Returns a `dict` with GraphQL query data that was not yet validated.


##### Required arguments

`query_params`: a `dict` with parsed query string.


#### `handle_get_explorer`

```python
def handle_get_explorer(self, environ: dict, start_response) -> List[bytes]:
...
```

Handles WSGI HTTP GET explorer request and returns a response to the client.

Returns list of bytes with response body.

Expand Down
42 changes: 42 additions & 0 deletions website/blog/2024-03-18-ariadne-0-23.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: Ariadne 0.23
---

Ariadne 0.23 is now out.

Ariadne 0.23 is a maintenance release that adds opt-in support for executing `query` operations over `GET` requests, bumps Apollo Federation support to 2.6 and addresses two small bugs.

<!--truncate-->

## Support for executing queries made with GET requests

Ariadne 0.23 brings support for query execution made with GET HTTP requests. Only “query” type operations are executed, “mutation” and “subscription” operations will raise errors.

This is useful for clients retrieving data from the GraphQL API that could be cached over the HTTP using solutions like Varnish.


## Added support for the Apollo Federation versions up to 2.6

Our amazing community has contributed a patch for Ariadne that increases support for Apollo Federation up to version 2.6.


## Fixed deprecation warnings in Apollo Tracing extension

For those few who are using Apollo Tracing extension for utility of seeing resolvers execution time in response’s JSON payload, we have fixed the deprecation warnings.


## Blocked `subscription` execution in POST requests

It was possible to send a “subscription” operation to Ariadne over POST HTTP request, and the query executor would attempt to execute it, skipping the `source` call and thus producing an error in a resolver expecting some payload.

Ariadne 0.23 includes an extra validation step that raises a dedicated error when this is attempted.


## CHANGELOG

- Added `execute_get_queries` setting to the `GraphQL` apps that controls execution of the GraphQL "query" operations made with GET requests. Defaults to `False`.
- Added support for the Apollo Federation versions up to 2.6.
- Fixed deprecation warnings in Apollo Tracing extension.
- Added a check to prevent `subscription` operation execution when a query is made with POST request.


Loading

0 comments on commit 2c9d2d4

Please sign in to comment.