From 9fd40714060c39d10a55b3a23f915b7c59b77b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Georget?= Date: Thu, 21 Apr 2016 17:10:05 +0200 Subject: [PATCH] Update documentation on GraphQL --- website/documentation/concepts/graphql.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/website/documentation/concepts/graphql.md b/website/documentation/concepts/graphql.md index 5614a373a4..9eaa8344ab 100755 --- a/website/documentation/concepts/graphql.md +++ b/website/documentation/concepts/graphql.md @@ -198,5 +198,14 @@ Then, you can apply one or more policies on each query and mutation. } ``` +## Use GraphQL in your codebase + +You can make GraphQL query in your codebase. The `graphql` is exposed in global, and Strapi add a new function called `query` to easily make GraphQL query. + +```javascript +this.body = yield graphql.query("{articles{title}}", this); +// Don't forget to send the context. This is needed to apply permissions. +``` + !!! note The policy doesn't need to be in the same API folder. The GraphQL permissions are based on the global `strapi.policies` variable which is an aggregate of the policies of the whole application. Also, the request is apply to the policies, in others words, this means you can handle sessions and cookies in the policy as usual.