About network access for Shopify Functions
Network access for Shopify Functions allows you to configure HTTP requests for your functions to use data from an external service as an input to your function logic. It's available primarily for merchants on Shopify for enterprises.
This guide introduces how Network access for Shopify Functions works and provides examples.
Availability of network access for functions
Anchor link to section titled "Availability of network access for functions"Function | Availability |
---|---|
Cart and Checkout Validation | Shopify for enterprises with custom apps |
Local Pickup Delivery Option Generator | Shopify for enterprises with custom apps (Early access) |
Pickup Point Delivery Option Generator | Shopify Plus with custom apps (Early access) |
Network access for functions needs to be enabled by Shopify, as it's currently not available on development stores or in a developer preview. Contact Support for more information about the available Shopify Functions that support network access.
How it works
Anchor link to section titled "How it works"Network Access for Shopify Functions enables you to define your HTTP request using the fetch target of the function. When your function is executed, Shopify performs the HTTP request and includes the response in the input of the run target.
The following diagram shows the different requests that occur with a function that has network access:
- The
fetch
function target defines an HTTP request based on the existing function input query. - The outcome of
FunctionFetchResult
conveys anHttpRequest
to be executed. Shopify schedules the request with optimizations.
Read more about network request caching in the Performance page.
Shopify executes network calls to the external service.
The
run
function target contains the main logic and has access to the HTTP response through the input query.The outcome of
FunctionRunResult
conveys the function’s final output.
Alternatives to network access
Anchor link to section titled "Alternatives to network access"Instead of fetching data with an external network call, consider retrieving the data from a metafield in your functions. Most objects support metafields, including products, locations, and customers.
Fetching data from metafields during checkout is more efficient as it doesn't involve an external network call. This lets you to depend on Shopify for the uptime, scalability, and durability of the data storage.
Use the GraphQL Admin or Storefront APIs to write metafields on the store before a buyer reaches checkout.
Developer tools and resources
Anchor link to section titled "Developer tools and resources"Explore the following developer tools and resources to learn more about network access for Shopify Functions.
- Learn how to use network access.