Update | Description |
---|---|
Change the client type |
Remix: Instead of creating an Non-Remix: Instead of creating a |
Change the method | Instead of using the get method on the REST client or the find , all , or count method on the resource class, use the query method on the GraphQL client. |
Add a query |
Pass a query to the client, requesting the information that you want to retrieve. Instead of specifying the path to the resource (like If you're retrieving a resource by its ID, then use the GraphQL API global ID (GID) for the resource (like |
Destructure the response |
GraphQL responses are typically nested within a data object. The structure of the data mirrors the structure of the query. To make the data easier to work with, destructure the object that's returned. You can also access properties of the object using dot notation ( |
Update | Description |
---|---|
Change the client type |
Remix: Instead of creating an Non-Remix: Instead of creating a |
Change the method | Instead of using the post , put , or delete method on the REST client, or the save or delete method on the resource class, use the query method on the GraphQL client. |
Add a mutation |
Instead of specifying the path to the resource (like |
Destructure the response |
GraphQL responses are typically nested within a data object, and the structure of the data often mirrors the structure of the mutation. To make the data easier to work with, destructure the object that's returned. You can also access properties of the object using dot notation ( |
Read userErrors |
Extract the userErrors array from the response. If the mutation wasn't completed, then this information is returned in this array. Learn about how error handling differs in GraphQL. |
Update | Description |
---|---|
Change the client type | Instead of creating a shopify.clients.Rest client or using REST resource classes like shopify.rest.Product.find , create a shopify.clients.GraphQL client. |
Change the method | Instead of using the get method on the REST client or the find , all , or count method on the resource class, use the query method on the GraphQL client. |
Add a query |
Pass a query to the client, requesting the information that you want to retrieve. Instead of specifying the path to a resource (like If you're retrieving a resource by its ID, then use the GraphQL API global ID (GID) for the resource (like |
Destructure the response |
GraphQL responses are typically nested within a data object. The structure of the data mirrors the structure of the query. To make the data easier to work with, destructure the object that's returned. You can also access properties of the object using bracket notation. In the provided Ruby example, the product data is accessed with |
Update | Description |
---|---|
Change the client type | Instead of creating a ShopifyAPI::Clients::Rest::Admin client or using REST resource classes like ShopifyAPI::Product , create a ShopifyAPI::Clients::Graphql::Admin client. |
Change the method | Instead of using the post , put , or delete method on the REST client, or the save or delete method on the resource class, use the query method on the GraphQL client. |
Add a mutation |
Instead of specifying the path to the resource (like |
Destructure the response |
GraphQL responses are typically nested within a data object, and the structure of the data often mirrors the structure of the mutation. To make the data easier to work with, destructure the object that's returned. You can also access properties of the object using dot notation ( |
Read userErrors |
Extract the userErrors array from the response. If the mutation wasn't completed, then this information is returned in this array. Learn about how error handling differs in GraphQL. |
Update | Description |
---|---|
Change the endpoint | Instead of a resource-specific endpoint (/products/1234.json ), use the generic GraphQL endpoint for the store. The details for the update that you want to make is now part of a GraphQL mutation that's passed in the request body. |
Change the method | If you're using a PUT or DELETE method, then update the method to POST . |
Add a query | Add a GraphQL mutation in the request body. In this example, we're creating a new product. |
Add query variables |
Pass the details for the resource that you want to create or update as query variable. If you're updating or deleting a resource, then instead of using a simple ID ( |
Destructure the response |
GraphQL responses are typically nested within a data object. The structure of the data mirrors the structure of the query. To make the data easier to work with, destructure the object that's returned. You can also access properties of the object using dot notation ( |
Read userErrors |
Extract the userErrors array from the response. If the mutation wasn't completed, then this information is returned in this array. Learn about how error handling differs in GraphQL. |