[MIDDLEWARE] middleware executed many times
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
Parti dalla configurazione di GraphQLView.as_view e DummyMiddleware.resolve mostrata nell’issue, quindi riproduci il comportamento con la query hello, una query di lista e la mutation logout. Confronta il numero di invocazioni del middleware e determina il comportamento previsto con una singola esecuzione prima di identificare quale componente ne è responsabile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi there, I'm using flask-graphql in a project and got into a question/issue I don't have many clues. I'm using middlewares; this is the minimum example:
from flask import Flask, request
from flask_graphql import GraphQLView
from graphene import Field, ObjectType, Schema, String, relay
class Hello(ObjectType):
message = String()
class Query(ObjectType):
hello = Field(Hello)
def resolve_hello(self, info):
return Hello(message="Hi there")
class DummyMiddleware(object):
def resolve(self, next, root, info, **kwargs):
print("DummyMiddleware")
return next(root, info, **kwargs)
dummy_middleware = DummyMiddleware()
schema = Schema(query=Query)
app = Flask(__name__)
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql',
schema=schema,
graphiql=True,
middleware=[dummy_middleware]))
if __name__ == "__main__":
app.run(host='0.0.0.0', threaded=True)
(The problem happens no matter the version; the problem also happens when launching the wsgi app with gunicorn).
If I query "hello()", the "DummyMiddleware" will appear twice. If I query a list of elements, the middleware is executed lots of time, twice per element it seems.
For a query this is just a problem of performance, but in a Logout() mutation what happens is:
- 1st time - the authenticated request is valid, so "logout()" deletes the token
- 2nd time - the authenticated request is not valid (because the token has been deleted), so it returns an error
Is there anything wrong in my approach to middlewares? I'm not sure which part is responsible (flask, graphql, my configuration...). Any hint would be appreciated.
- Lingua principale
- Python
- Stelle
- 1.3k
- Fork
- 139
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di graphql-python/flask-graphql
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
graphql-python/flask-graphql#92 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
graphql-python/flask-graphql#85 · 2 commenti · 1 reazione ·
-
CSRF Exemption? Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
graphql-python/flask-graphql#84 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
graphql-python/flask-graphql#80 · 9 commenti · 2 reazioni ·
Tutte le issue di graphql-python/flask-graphql
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
anthropics/skills#1811 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
speaches-ai/speaches#678 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
datalayer/mcp-compose#42 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
conda-forge/spacy-feedstock#177 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
UKGovernmentBEIS/inspect_evals#2523 ·