graphql-python / graphql-python/flask-graphql

Proposal: Pass custom variables to graphiql template

Aperta
#35 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
1.3k
Fork
139
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi !

It would be nice to be able to pass arbitrary variables to the graphiql template. I didn't found how to do it and looking at how `render_graphiql.py` is called, it seems that this is not possible.

I found a workaround by pre-formatting my template before passing it to `GraphQLView.as_view()` but it felt awkward.
Maybe something like this would look nicer:

```python
view_func = GraphQLView.as_view(
url,
schema,
graphiql=True,
graphiql_template=my_custom_template,
graphiql_template_context={"username": username} # Now I can greet the user on my custom page !
)
```

If you guys are interested by this proposal let me know and I'll do a PR in the next few days.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.