Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def view(schema):
return GraphQLView.as_view(schema=schema)
def execute_query(request_factory, schema, query, **kwargs):
view = GraphQLView.as_view(schema=schema, **kwargs)
request = request_factory.post(
"/graphql/", data=query, content_type="application/json"
)
response = view(request)
return json.loads(response.content)
def register_urlpatterns(self, urlpatterns):
# GraphQL API
urlpatterns.namespace(r"^graphql/", "graphql")
urlpatterns.patterns(
"graphql", url(r"^$", GraphQLView.as_view(schema=schema), name="index")
)