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

Add graphiql options and missing flask context #55

Merged
merged 4 commits into from
Jul 27, 2020

Conversation

KingDarBoja
Copy link
Contributor

@KingDarBoja KingDarBoja commented Jul 11, 2020

This add support for graphiql options like as:

  • default_query: An optional GraphQL string to use when no query is provided and no stored query exists from a previous session. If not provided, GraphiQL will use its own default query.
  • header_editor_enabled: An optional boolean which enables the header editor when true. Defaults to false.
  • should_persist_headers: An optional boolean which enables to persist headers to storage when true. Defaults to false.

Also, add the missing context attribute as requested at this old flask-graphql#52 issue.

However, the approach I used for all 4 servers (flask, aiohttp, webob, sanic) was based on this sanic#8 issue which was solved at this pull request.

There are other related issues as well on each server integrations:

As far as I know, this context will be passed to the execute method on GraphQL, which will be passed to all resolve functions as stated on GraphQL-JS docs. At the end, this will be part of the GraphQLResolveInfo, which is used by resolve_field_value_or_error to resolve the field.

Based on that, I am not 100% sure if it the correct way of handling custom context for all server integrations so any suggestion is welcome!

@KingDarBoja KingDarBoja added type: bug An issue or pull request relating to a bug type: feature A new feature labels Jul 11, 2020
@KingDarBoja KingDarBoja self-assigned this Jul 11, 2020
@KingDarBoja KingDarBoja requested a review from dfee July 11, 2020 22:46
@KingDarBoja
Copy link
Contributor Author

After reading a bit regarding what context is used for, I submitted another commit with a possible test suite to ensure and help others to understand the proper functionality of context using Flask as example.

Copy link
Member

@jkimbo jkimbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some left over print statements need to be removed but otherwise looks good.

tests/flask/test_graphqlview.py Outdated Show resolved Hide resolved
@KingDarBoja KingDarBoja merged commit cf6d1d4 into graphql-python:master Jul 27, 2020
@KingDarBoja KingDarBoja deleted the graphiql-options branch July 27, 2020 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug type: feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants