Skip to content

Allow contexts provided to resolvers to have attributes #105

Closed
@leonardwellthy

Description

@leonardwellthy

(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions