I would be interested to hear about how you did pyramid and graphql, ive been following graphene but are there specific tie ins for pyramid? books? articles?
Simply add a /graphql view to your Pyramid app such as:
from cornice import Service
from pyramid.exceptions import HTTPBadRequest
from ..schemas import schema
graphql = Service(
name='graphql',
path='/graphql',
description="GraphQL",
accept='application/json',
renderer='json',
)
@graphql.post(permission='readwrite')
def post_graphql(request):
query = request.json_body.get('query')
variables = request.json_body.get('variables', None)
if not query:
raise HTTPBadRequest
return schema.execute(query, variable_values=variables, context_value={
'dbsession': request.dbsession,
'user_id': request.authenticated_userid,
})