-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from tartiflette/ISSUE-55
ISSUE-55 - Provides a context factory parameter
- Loading branch information
Showing
10 changed files
with
116 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# [1.1.0] -- 2019-10-02 | ||
|
||
## Added | ||
|
||
- [ISSUE-55](https://github.com/tartiflette/tartiflette-aiohttp/issues/55) - Add | ||
a new optional `context_factory` parameter to the `register_graphql_handlers` | ||
function. This parameter can take a coroutine function which will be called on | ||
each request with the following signature: | ||
```python | ||
async def context_factory( | ||
context: Dict[str, Any], req: "aiohttp.web.Request" | ||
) -> Dict[str, Any]: | ||
""" | ||
Generates a new context. | ||
:param context: the value filled in through the `executor_context` | ||
parameter | ||
:param req: the incoming aiohttp request instance | ||
:type context: Dict[str, Any] | ||
:type req: aiohttp.web.Request | ||
:return: the context for the incoming request | ||
:rtype: Dict[str, Any] | ||
""" | ||
``` | ||
|
||
The aim of this function will be to returns the context which will be forwarded | ||
to the Tartiflette engine on the `execute` or `subscribe` method. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# [next] | ||
# [Next] | ||
|
||
## Added | ||
|
||
## Changed | ||
|
||
## Fixed | ||
## Fixed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import Any, Dict | ||
|
||
__all__ = ("default_context_factory",) | ||
|
||
|
||
async def default_context_factory( | ||
context: Dict[str, Any], req: "aiohttp.web.Request" | ||
) -> Dict[str, Any]: | ||
""" | ||
Generates a new context. | ||
:param context: the value filled in through the `executor_context` | ||
parameter | ||
:param req: the incoming aiohttp request instance | ||
:type context: Dict[str, Any] | ||
:type req: aiohttp.web.Request | ||
:return: the context for the incoming request | ||
:rtype: Dict[str, Any] | ||
""" | ||
return {**context, "req": req} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters