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 execution context class to graphql kwargs #65

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jeroenmuller
Copy link

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

@@ -14,8 +14,7 @@
from ariadne.types import ContextValue, ErrorFormatter, ExtensionList, RootValue, ValidationRules

from graphql import GraphQLSchema
from graphql.execution import MiddlewareManager
Copy link

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]:
Copy link

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from graphql import ExecutionContext, GraphQLBoolean, GraphQLResolveInfo, GraphQLScalarType
from graphql import ExecutionContext, GraphQLBoolean, GraphQLResolveInfo, GraphQLScalarType

Please format code with black.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants