useShopQuery
The useShopQuery
hook allows you to make server-only GraphQL queries to the Storefront API. It must be a descendent of a ShopifyProvider
component.
Example code
Anchor link to section titled "Example code"
The useShopQuery
takes an object as its only argument, with the following keys:
Key | Required | Description |
---|---|---|
query |
Yes | A string of the GraphQL query. |
variables |
No | An object of the variables for the GraphQL query. |
cache |
No | The caching strategy to help you determine which cache control header to set. |
preload |
No | Whether to preload the request. It defaults to true only when the CachingStrategy is not CacheNone . Specify false to disable or use '*' to preload the query for all requests. |
Return value
Anchor link to section titled "Return value"The useShopQuery
returns an object with the following key:
Key | Description |
---|---|
data |
The data returned by the query. |