graphql-python / graphql-python/flask-graphql
Proposal: Pass custom variables to graphiql template
- Linguagem predominante
- Python
- Estrelas
- 1.3k
- Forks
- 139
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Comece lendo render_graphiql.py e o ponto de entrada GraphQLView.as_view() para entender como o template GraphiQL é renderizado. Adicione suporte para passar um contexto de template arbitrário pela configuração da view e verifique se uma variável personalizada como username está disponível no template renderizado.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- flask, python
- Domínio
- api, backend
- Tipo de issue
- Funcionalidade
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 48/100