
$query = <<

Next, I’m going to setup my simple app by typing composer init. I’m going to use Guzzle as my HTTP client in this case.įirst, let’s install Composer, the de-facto package manager for PHP.


All you need is a way to make a HTTP request, and the ability to parse JSON. I’m going to build this in PHP, but the concepts are applicable to almost any language. As a query and a mutation can both take input data, we use a POST to submit to the server, and receive JSON in response. In GraphQL, a query always fetches data and a mutation always manipulates data. GraphQL is a different paradigm to something like REST, where the HTTP verb dictates the behavior. It’s served over HTTPS, and the only HTTP verb you need to use is POST. Using the Sonar GraphQL API in an external application is pretty simple. Now let’s build a very simple application so we can consume the API externally. In the first three articles in this series, I walked you through how to use the API using GraphiQL, a web based tool included in Sonar.
