Description
(I filed this issue as graphql-python/graphene-mongo#198 in graphene-mongo, but possibly the solution should be implemented in graphql-server)
A graphql resolver function is provided a context which can hold important information like the currently logged in user or the current HTTP request
In Graphene, graphene-django, graphene-mongo and the old flask-graphql , the context is an object that can have attributes read and written to it (for example context.db.loadHumanByID(args.id)
). However, graphql-server provides a dict that must be accessed by key name e.g. context['request']
If we were programming in Javascript, both syntaxes would work. It would be nice if the context provided by graphql-server could be made more flexible, for instance by making the default context a collections.UserDict
.
edit: I see now that the class property context
on the GraphQLView can be specified, so that let's me workaround my particular use case