Giter Club home page Giter Club logo

Comments (4)

messa avatar messa commented on June 10, 2024 2

Looks like context is request (if you haven't overrided it): https://github.com/graphql-python/flask-graphql/blob/master/flask_graphql/graphqlview.py#L41

So probably info.context is request, and headers are in info.context.headers, but I haven't verified it.

from flask-graphql.

paymog avatar paymog commented on June 10, 2024

Oh, looks like

from flask import request

def resolve_latest_snapshot(self, info: ResolveInfo, org_id: Optional[int] = None) -> models.Snapshot:
    print(request.headers)
    # more stuff

works. I wonder if there's a better, more graphene-y solution...

from flask-graphql.

paymog avatar paymog commented on June 10, 2024

from flask-graphql.

m3talstorm avatar m3talstorm commented on June 10, 2024

When trying to access info.context in mutation I get

"graphql.error.located_error.GraphQLLocatedError: Working outside of request context"

Pretty simple setup:


class SomeMutation(graphene.Mutation):
    """
    """
    
    def mutate(self, info):
        """
        """

        print(info.context)
         ... snip...

        return


class Mutation(graphene.ObjectType):
    """
    """

    some_mutation = SomeMutation.Field()



schema = graphene.Schema(query=Query, mutation=Mutation, subscription=Subscription)


app.add_url_rule('/graphql',
    view_func=GraphQLView.as_view('graphql',
        schema=schema,
        batch=True,
        graphiql=False,
        executor=GeventExecutor(),
    )
)

from flask-graphql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.