Comments (8)
Probably checking Content-Type (either application/graphql
or application/json
) would be saner.
from graphene-gae.
hey @uebayasi ,
do _get_graphql_params
starts with this code:
try:
request_data = self.request.json_body
if isinstance(request_data, basestring):
request_data = dict(query=request_data)
except:
request_data = {}
Meaning, if you send a JSON object ({ "query": "...", "variables": "..." }
) it'll use that, and if you send a JSON string it'll treat is as the query
.
The code that follows reads operation_name
and variables
from request_data
.
So if you send a POST request that looks like { "query": "...", "variables": "..." }
GraphQLHandler should handle it properly.
Are you having problems with such a request?
The reason this handler is implemented in graphene-gae
and not graphene
is that its written specifically for the Google AppEngine environment - using webapp2
which is GAE's web framework.
The main graphene
library should not depend on GAE specific code thats of no use to people on other platforms.
from graphene-gae.
Thanks for the quick reply!
Now I see the problem; self.request.json_body
is failing for me. I grep -r'ed json_body
under google-cloud-sdk/platform/google_appengine/lib/webapp2-*
and got no result. There are references under other subdirectories but I have no idea of relevance.
json.loads(self.request.body)
surely works and that's I'm using it for now.
This is google-cloud-sdk 132.0.0 (2016/10/19).
from graphene-gae.
In requests.py there's this code:
def _json_body__get(self):
"""Access the body of the request as JSON"""
return json.loads(self.body.decode(self.charset))
def _json_body__set(self, value):
self.body = json.dumps(value, separators=(',', ':')).encode(self.charset)
def _json_body__del(self):
del self.body
json = json_body = property(_json_body__get, _json_body__set, _json_body__del)
So basically self.request.json_body
is the same as doing json.loads(self.request.body.decode(self.charset))
from graphene-gae.
This is part of the webob 1.2.3 library that webapp2 depends on
from graphene-gae.
I see that webapp2-2.5.1 and webob-1.2.3 are used (imported) here. I can't figure out why those inherited methods are called.
I'll try to investigate this later, but I can't promise. Feeling like Python not being my friend. :(
from graphene-gae.
For some reasons the request
object inherits class BaseRequest
in webob-1.1.1/webob/request.py, where _json_body__get
is not defined. webob-1.2.3's class BaseRequest
does define it.
Obviously this problem is not relevant to graphene-gae. It is either google-gcloud-sdk or python2.7 or my local environment causing the oddity. Feel free to close this issue.
Fortunately my project is not really started yet. I'm considering to switch to something and stay away from Python if possible... :(
from graphene-gae.
I just ran into this issue on a fresh install of Google Cloud SDK. It seems that webob
version 1.1 gets loaded even though 1.2 is available. I fixed it by specifying the newer webob
in my app.yaml
:
libraries:
- name: webob
version: 1.2.3
- name: webapp2
version: 2.5.2
from graphene-gae.
Related Issues (18)
- GraphiQL Integration for Webapp2 HOT 7
- Docs page does not exist HOT 3
- KeyProperty not showing up in schema HOT 2
- Version bump? HOT 2
- TimeProperty HOT 3
- PolyModel HOT 2
- Expected value of type "UserType" but got: User HOT 3
- app.yaml handlers? HOT 1
- GraphQL Integration for Cloud Endpoints
- How do you filter? HOT 1
- NDBConnectionField
- Is it possible to use google-cloud-ndb with this package?
- ndb.GeoPtProperty support
- Looking for maintainers! HOT 4
- Support AppEngine Flexible Environment (gcloud library in addition to ndb)
- ndb.ComputedFields support
- Support ndb.LocalStructuredProperty (and their Repeated version)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphene-gae.