Info |
---|
This page is focused on access to the developer GraphQL API. See the documentation for a specific endpoint for information on how to access that endpoint. |
In order to interact with GraphQL you will likely choose to use a GraphQL client, rather than making direct HTTP requests. There are many different clients available as independent software, or as extensions to existing browsers or IDEs. Below we describe a few common clients and how they are configured to access Totara's GraphQL APIs.
Table of Contents | ||
---|---|---|
|
Postman
There are a few ways to use Postman, but our recommendation would be to create a collection for your Totara API requests.
Create a collection with Authorization set to No Auth:
...
Create a HTTP request (not a GraphQL request) and set as follows:
Request URL: https http://YOUR-SITE-URL/totara/webapi/dev_graphql_executor.php
Request Method: POST
On Body tab, select GraphQL
...
Ensure YOUR-SITE-URL matches your site's wwwroot.
Next, click Cookies (the blue link on far right), and select Add Cookie:
...
You will need to specify the name and value for the Totara session cookie:
...
The session cookie value can be obtained by logging in install the Postman Interceptor browser extension
Follow the steps to ‘Sync Cookies’ using your site’s wwwroot, e.g. integration.totara83
from the Postman documentation here
Once your cookies are synced to Postman Desktop, sign in to your Totara site in your browser as the user you want to use (via the same URL as you entered above). Next, open your browser's developer tools and locate the Totara Session cookie. For Google Chrome, this is under Application > Storage > Cookies. Normally you are looking for the value of the TotaraSession cookie:
...
If you have customised the session cookie prefix under Quick-access menu > Server > Session handling > Cookie prefix, it may have a different name. Similarly, you might have multiple cookies on the same server, so look for the one with the path that matches the site's URL.
Once you've saved the cookie, you run the requests as
You can then enter a query and variables into the page and click Send to make the request. Schema auto-completion should be working as you write the query and you should get results in the bottom window like this:
...
When the logged-in user's browser session expires you will need to repeat the steps above to enter the new TotaraSession cookie value.PHPStormIf your Totara user session expires you’ll need to log in to the site again
PHPStorm GraphQL Plugin
GraphQL integration within PHPStorm is achieved via the JS GraphQL plugin. Install this plugin via Preferences > Plugins:
...