-
Notifications
You must be signed in to change notification settings - Fork 11
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 execution context class to graphql kwargs #65
base: main
Are you sure you want to change the base?
Add execution context class to graphql kwargs #65
Conversation
@@ -14,8 +14,7 @@ | |||
from ariadne.types import ContextValue, ErrorFormatter, ExtensionList, RootValue, ValidationRules | |||
|
|||
from graphql import GraphQLSchema | |||
from graphql.execution import MiddlewareManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please order imports alphabetically.
} | ||
|
||
def get_context_for_request(self, request: HttpRequest) -> Optional[ContextValue]: | ||
def get_context_for_request(self, request: HttpRequest, data=None) -> Optional[ContextValue]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data
needs type
# From ariadne 0.20 Extension supports both sync and async contexts | ||
# https://github.com/mirumee/ariadne/blob/main/CHANGELOG.md#020-2023-06-21 | ||
from ariadne.types import Extension as ExtensionSync | ||
from graphql import ExecutionContext, GraphQLBoolean, GraphQLResolveInfo, GraphQLScalarType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from graphql import ExecutionContext, GraphQLBoolean, GraphQLResolveInfo, GraphQLScalarType | |
from graphql import ExecutionContext, GraphQLBoolean, GraphQLResolveInfo, GraphQLScalarType |
Please format code with black.
Since ariadne 0.18 it is possible to change the execution context class. This makes it possible to use an execution context that supports deferred execution of dataloaders: https://github.com/jkimbo/graphql-sync-dataloaders
As ariadne-django has not been updated to ariadne 0.18 yet, it does not pass the
execution_context_class
parameter to ariadne. I made some changes to add this to the list of arguments in get_kwargs_graphql.Since this would require at least ariadne 0.18, I increased the version of the dependency. I also made some small changes that were neccessary to get the tests to run with API changes in newer versions of ariande