1. Reference: Requesting Shopify’s GraphQL Admin API in Altair GraphQL Client. I finally decided to try using Postman again.
2. Reference: https://learning.postman.com/docs/sending-requests/supported-api-frameworks/graphql/ . Querying with GraphQL
3. Send a GraphQL query in the request body. Open a new request tab in Postman and enter your GraphQL endpoint URL in the address bar. Select POST from the request method dropdown list. Under the Body tab, select the GraphQL body type. Enter your GraphQL query in the query editor. You need to set the Headers: Content-Type: application/graphql, X-Shopify-Access-Token: {access_token}, as shown in Figure 1.

{
products(first: 3) {
edges {
node {
id
title
}
}
}
}
4. Use GraphQL variables. Enter your GraphQL variables in the GraphQL variables editor. In the query editor, declare the GraphQL variables within the GraphQL query, as shown in Figure 2.

query ($first: Int!){
products(first: $first) {
edges {
node {
id
title
}
}
}
}
{
"first": 3
}
5. To enable autocomplete, you need to add a GraphQL schema. Create or import a GraphQL schema in Postman. Therefore, you first need to obtain the GraphQL schema via the Altair GraphQL Client. Inspect the network requests, click reload document, and copy the response parameters, as shown in Figure 3.

6. Paste it into the file schema.graphql. Its size is about 2 MB, as shown in Figure 4.

7. Select API in the left sidebar, then select + to create a new API. Enter a name and version for the API. Select GraphQL from the Schema type dropdown list. Select GraphQL SDL from the Schema Format dropdown list. Select Import. Import local schema files, as shown in Figure 5.

8. Enable GraphQL query autocomplete. Select your schema from the dropdown list: Shopify’s GraphQL Admin API. Postman will now suggest autocomplete options based on the data in the new GraphQL schema. However, an error is prompted: incorrert schema. Autocomplete options related to the schema will not work., as shown in Figure 6.


9. Reference URL: https://www.npmjs.com/package/graphql-introspection-json-to-sdl , convert the format from GraphQL introspection JSON to GraphQL SDL.
PS E:\wwwroot\shopify-graphql> npm install graphql-introspection-json-to-sdl
added 7 packages, and audited 8 packages in 15s
found 0 vulnerabilities
PS E:\wwwroot\shopify-graphql> ls
Directory: E:\wwwroot\shopify-graphql
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2022/2/21 14:08 node_modules
-a---- 2022/2/21 14:08 4632 package-lock.json
-a---- 2022/2/21 14:08 78 package.json
-a---- 2022/2/21 13:59 6115414 schema.json
PS E:\wwwroot\shopify-graphql> graphql-introspection-json-to-sdl schema.json > schema.graphql
graphql-introspection-json-to-sdl : Unable to load file C:\Users\Lenovo\AppData\Roaming\np
m\graphql-introspection-json-to-sdl.ps1, because running scripts is disabled on this system. For more information,
see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170
.
Location: Line:1 Character: 1
+ graphql-introspection-json-to-sdl schema.json > schema.graphql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS E:\wwwroot\shopify-graphql> get-executionpolicy
Restricted
PS E:\wwwroot\shopify-graphql> set-executionpolicy remotesigned
Execution Policy Change
Execution policies help you prevent execution of untrusted scripts. Changing the execution policy might pose a security risk, as
described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes(Y) [A] Yes to All(A) [N] No(N) [L] No to All(L) [S] Suspend(S) [?] Help
(default is "N"):Y
PS E:\wwwroot\shopify-graphql> graphql-introspection-json-to-sdl schema.json > schema.graphql
PS E:\wwwroot\shopify-graphql> ls
Directory: E:\wwwroot\shopify-graphql
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2022/2/21 14:08 node_modules
-a---- 2022/2/21 14:08 4632 package-lock.json
-a---- 2022/2/21 14:08 78 package.json
-a---- 2022/2/21 16:10 2015866 schema.graphql
-a---- 2022/2/21 16:01 2128569 schema.json
PS E:\wwwroot\shopify-graphql>
10. Import the Schema file again, and the error is no longer prompted. Autocomplete is available. However, introspecting the schema in Postman requires manual import every time, and it does not support automatic updating based on requests, as shown in Figure 7.

