Skip to content

Commit c44e123

Browse files
committed
Support variables in API requests
1 parent 65e59a5 commit c44e123

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/Package/Graphql.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ class Graphql extends AbstractPackage
2222
/**
2323
* Execute a query against the GraphQL API.
2424
*
25-
* @param string $query The query to perform.
25+
* @param string $query The query to perform.
26+
* @param array $variables An optional array of variables to include in the request.
2627
*
2728
* @return string
2829
*
2930
* @since __DEPLOY_VERSION__
3031
*/
31-
public function execute($query)
32+
public function execute($query, array $variables = array())
3233
{
3334
// Build the request path.
3435
$path = '/graphql';
@@ -41,6 +42,11 @@ public function execute($query)
4142
'query' => $query,
4243
);
4344

45+
if (!empty($variables))
46+
{
47+
$data['variables'] = $variables;
48+
}
49+
4450
// Send the request.
4551
return $this->processResponse(
4652
$this->client->post($this->fetchUrl($path), $data, $headers),

0 commit comments

Comments
 (0)