Skip to content

Add ability to pass execution_context_class to GraphQLView.as_view()#1109

Merged
zbyte64 merged 2 commits intographql-python:mainfrom
kubami:patch-1
Mar 31, 2021
Merged

Add ability to pass execution_context_class to GraphQLView.as_view()#1109
zbyte64 merged 2 commits intographql-python:mainfrom
kubami:patch-1

Conversation

@kubami
Copy link
Contributor

@kubami kubami commented Feb 3, 2021

Currently when passing execution_context_class like this:

GraphQLView.as_view(execution_context_class=CustomContext)

you get the following error from View.as_view()

TypeError: GraphQLView() received an invalid keyword 'execution_context_class'. as_view only accepts arguments that are already attributes of the class.

this PR fixes the hasattr check in .as_view.

Fixes: #1072

Currently when passing `execution_context_class` like this:

```
GraphQLView.as_view(execution_context_class=CustomContext)
```

you get the following error from `View.as_view()`
```
TypeError: GraphQLView() received an invalid keyword 'execution_context_class'. as_view only accepts arguments that are already attributes of the class.
```

this PR fixes the `hasattr` check in `.as_view`.

Fixes: graphql-python#1072
removed whitespace
@zbyte64
Copy link
Collaborator

zbyte64 commented Feb 4, 2021

Great catch. Would like to add a test for this, let me know if you're up for it, otherwise we'll merge as is.

@kubami
Copy link
Contributor Author

kubami commented Mar 5, 2021

Hi @zbyte64 thanks for looking at this. As you can see I am a bit strapped for time at this moment. Let's merge it as is.

@kubami
Copy link
Contributor Author

kubami commented Mar 25, 2021

Is it possible to merge this in as is?

@zbyte64 zbyte64 merged commit 3cf940d into graphql-python:main Mar 31, 2021
@weilu
Copy link

weilu commented Jun 9, 2021

This got me too. Can we have this released please? On a somewhat relevant note, per fail fast principle can we have UnforgivingExecutionContext be the default context so graphene doesn't swallow exceptions?

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.

Catching GraphQLLocatedError for tests

4 participants