Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Pass custom variables to graphiql template #35

Open
Morreski opened this issue Oct 10, 2017 · 0 comments
Open

Proposal: Pass custom variables to graphiql template #35

Morreski opened this issue Oct 10, 2017 · 0 comments

Comments

@Morreski
Copy link

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:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant