graphql-python / graphql-python/flask-graphql

passing context to GraphQLView no more supported?

Ouverte
#52 10 commentaires 11 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
1.3k
Forks
139
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

Hi and thanks for the geat job.

With 1.4.1 version I used to pass my DB session via the `context` option of the GraphQLView as still mentioned in the README (which should be updated).

Below is an exemple of what I was doing:

```python
# [...]

db_session = scoped_session(
sessionmaker(autocommit=False, autoflush=False, bind=engine))

# [...]

app.add_url_rule(
'/graphql', view_func=GraphQLView.as_view(
'graphql', schema=SCHEMA, graphiql=True,
context={'session': db_session}))

# [...]
```

It seems this is no more possible and I can't figure out how to pass the DB session to the GraphQLView. Any information and/or updated doc would be nice.

Any solution to continue passing DB session via the GraphQLView (or by any other way allowing to pass it at execution time) would be perfect.

**EDIT: for an undocumented but working solution [see @cockscomb 's comment](https://github.com/graphql-python/flask-graphql/issues/52#issuecomment-412773200)**

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Start with the README's GraphQLView context example and the GraphQLView entry point, then compare the 1.4.1 behavior with the undocumented workaround in the linked comment. Done means confirming a supported way to pass the database session at execution time and updating the README or behavior accordingly.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
graphql, python
Domaine
api, backend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.