You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The GraphQL Admin API is a GraphQL-based alternative to the REST-based Admin API, and makes the functionality of the Shopify admin available at a single GraphQL endpoint. The full set of supported types can be found in the [GraphQL Admin API reference](https://help.shopify.com/en/api/graphql-admin-api/reference).
239
+
You can simply call the GraphQL resource and make a post request with a GraphQL string:
240
+
241
+
> The GraphQL Admin API requires an access token for making authenticated requests. So it won't work with `ApiKey` and `Password` which is allowed for REST API resources.
242
+
243
+
```php
244
+
$graphQL = <<<Query
245
+
query{
246
+
shop{
247
+
name
248
+
primaryDomain{
249
+
url
250
+
host
251
+
}
252
+
}
253
+
}
254
+
Query;
255
+
256
+
$data = $shopify->GraphQL->post($graphQL);
257
+
```
258
+
259
+
##### GraphQL Builder
260
+
This SDK only accepts a GraphQL string as input. You can build your GraphQL from [Shopify GraphQL Builder](https://help.shopify.com/en/api/graphql-admin-api/graphiql-builder)
261
+
262
+
237
263
### Resource Mapping
238
264
Some resources are available directly, some resources are only available through parent resources and a few resources can be accessed both ways. It is recommended that you see the details in the related Shopify API Reference page about each resource. Each resource name here is linked to related Shopify API Reference page.
239
265
> Use the resources only by listed resource map. Trying to get a resource directly which is only available through parent resource may end up with errors.
@@ -252,6 +278,7 @@ Some resources are available directly, some resources are only available through
There are several action methods which can be called without calling the `get()`, `post()`, `put()`, `delete()` methods directly, but eventually results in a custom call to one of those methods.
* @see https://help.shopify.com/en/api/graphql-admin-api GraphQL Admin API
9
+
*/
10
+
11
+
namespacePHPShopify;
12
+
13
+
14
+
usePHPShopify\Exception\SdkException;
15
+
16
+
class GraphQL extends ShopifyResource
17
+
{
18
+
19
+
/**
20
+
* @inheritdoc
21
+
*/
22
+
protectedfunctiongetResourcePath()
23
+
{
24
+
return'graphql';
25
+
}
26
+
27
+
/**
28
+
* Call POST method for any GraphQL request
29
+
*
30
+
* @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.
31
+
* @param string $url
32
+
* @param bool $wrapData
33
+
*
34
+
* @uses HttpRequestGraphQL::post() to send the HTTP request
0 commit comments