Would it be possible to refactor this:
https://github.com/datadvance/DjangoChannelsGraphqlWs/blob/09a2ffdde45a1553abd09b5b3e595402b6e6c9b1/channels_graphql_ws/graphql_ws_consumer.py#L537-L542
into its own get_context method, which a user could override in a custom subclass of the GraphqlWsConsumer if they want to inject something into the context?
Currently I'm injecting my own fields by overriding _on_gql_start__subscribe and injecting the fields before passing it on to the super function, which seemed to be the least impactful place to do it. But I just found out that queries and mutations don't pass through that function, meaning I would have to copy-paste the entire _on_gql_start method from the source into my override class just to add my own fields to the context...
A get_context method would make this trivial and very user friendly. It would also mimic how graphene-django provides this functionality to its users:
https://github.com/graphql-python/graphene-django/blob/e950164c8ee2a9babf54a0c2d3da27194d7cfddc/graphene_django/views.py#L139-L140
Would it be possible to refactor this:
https://github.com/datadvance/DjangoChannelsGraphqlWs/blob/09a2ffdde45a1553abd09b5b3e595402b6e6c9b1/channels_graphql_ws/graphql_ws_consumer.py#L537-L542
into its own get_context method, which a user could override in a custom subclass of the GraphqlWsConsumer if they want to inject something into the context?
Currently I'm injecting my own fields by overriding
_on_gql_start__subscribeand injecting the fields before passing it on to the super function, which seemed to be the least impactful place to do it. But I just found out that queries and mutations don't pass through that function, meaning I would have to copy-paste the entire_on_gql_startmethod from the source into my override class just to add my own fields to the context...A
get_contextmethod would make this trivial and very user friendly. It would also mimic how graphene-django provides this functionality to its users:https://github.com/graphql-python/graphene-django/blob/e950164c8ee2a9babf54a0c2d3da27194d7cfddc/graphene_django/views.py#L139-L140