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

Merge flask-graphql #37

Merged
merged 13 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 196 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,203 @@
*.pyc
*.pyo

# Created by https://www.gitignore.io/api/python,intellij+all,visualstudiocode
# Edit at https://www.gitignore.io/?templates=python,intellij+all,visualstudiocode

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360

.idea/

# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr

# Sonarlint plugin
.idea/sonarlint

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
*.egg-info
MANIFEST

.cache
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.idea
.mypy_cache
.pytest_cache
.tox
.venv
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

### VisualStudioCode ###
.vscode

/build/
/dist/
### VisualStudioCode Patch ###
# Ignore all local history of files
.history

docs
# End of https://www.gitignore.io/api/python,intellij+all,visualstudiocode
7 changes: 4 additions & 3 deletions graphql_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"GraphQLResponse",
"ServerResponse",
"format_execution_result",
"format_error_default",
]


Expand Down Expand Up @@ -230,11 +231,11 @@ def get_response(
as a parameter.
"""

if not params.query:
raise HttpQueryError(400, "Must provide query string.")

# noinspection PyBroadException
try:
if not params.query:
raise HttpQueryError(400, "Must provide query string.")
jkimbo marked this conversation as resolved.
Show resolved Hide resolved

# Parse document to trigger a new HttpQueryError if allow_only_query is True
try:
document = parse(params.query)
Expand Down
4 changes: 4 additions & 0 deletions graphql_server/flask/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .blueprint import GraphQL
from .graphqlview import GraphQLView

__all__ = ["GraphQL", "GraphQLView"]
21 changes: 21 additions & 0 deletions graphql_server/flask/blueprint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import warnings

from flask import Blueprint

from .graphqlview import GraphQLView


class GraphQL(object):
def __init__(self, app, schema, **options):
self.app = app
warnings.warn(
"GraphQL Blueprint is now deprecated, please use GraphQLView directly"
)
KingDarBoja marked this conversation as resolved.
Show resolved Hide resolved
self.blueprint = Blueprint("graphql", __name__, template_folder="templates")

app.add_url_rule(
"/graphql",
view_func=GraphQLView.as_view("graphql", schema=schema, **options),
)

self.app.register_blueprint(self.blueprint)
Loading