-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathGraphQL.php
78 lines (67 loc) · 1.98 KB
/
GraphQL.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* Created by PhpStorm.
* User: Tareq
* Date: 5/27/2019
* Time: 12:36 PM
*
* @see https://help.shopify.com/en/api/graphql-admin-api GraphQL Admin API
*/
namespace PHPShopify;
use PHPShopify\Exception\ApiException;
use PHPShopify\Exception\CurlException;
use PHPShopify\Exception\SdkException;
class GraphQL extends ShopifyResource
{
/**
* @inheritdoc
*/
protected function getResourcePath()
{
return 'graphql';
}
/**
* Call POST method for any GraphQL request
*
* @param string $graphQL A valid GraphQL String. @see https://help.shopify.com/en/api/graphql-admin-api/graphiql-builder GraphiQL builder - you can build your graphql string from here.
* @param string $url
* @param bool $wrapData
* @param array|null $variables
*
* @uses HttpRequestGraphQL::post() to send the HTTP request
* @throws ApiException if the response has an error specified
* @throws CurlException if response received with unexpected HTTP code.
*
* @return array
*/
public function post($graphQL, $url = null, $wrapData = false, $variables = null)
{
if (!$url) $url = $this->generateUrl();
$response = HttpRequestGraphQL::post($url, $graphQL, $this->httpHeaders, $variables);
return $this->processResponse($response);
}
/**
* @inheritdoc
* @throws SdkException
*/
public function get($urlParams = array(), $url = null, $dataKey = null)
{
throw new SdkException("Only POST method is allowed for GraphQL!");
}
/**
* @inheritdoc
* @throws SdkException
*/
public function put($dataArray, $url = null, $wrapData = true)
{
throw new SdkException("Only POST method is allowed for GraphQL!");
}
/**
* @inheritdoc
* @throws SdkException
*/
public function delete($urlParams = array(), $url = null)
{
throw new SdkException("Only POST method is allowed for GraphQL!");
}
}