File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed
packages/gatsby-source-shopify Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ plugins: [
3737 // The domain name of your Shopify shop. This is required.
3838 // Example: 'gatsby-source-shopify-test-shop' if your Shopify address is
3939 // 'gatsby-source-shopify-test-shop.myshopify.com'.
40+ // If you are running your shop on a custom domain, you need to use that
41+ // as the shop name, without a trailing slash, for example:
42+ // shopName: "gatsby-shop.com",
4043 shopName: " gatsby-source-shopify-test-shop" ,
4144
4245 // An API access token to your Shopify shop. This is required.
Original file line number Diff line number Diff line change 1+ const { createClient } = require ( `../create-client` )
2+
3+ describe ( `create-client` , ( ) => {
4+ it ( `Allows a domain as shop name` , ( ) => {
5+ expect ( createClient ( `my-shop.com` , `token` ) . url ) . toEqual (
6+ expect . not . stringContaining ( `myshopify.com` )
7+ )
8+ } )
9+
10+ it ( `Allows a non-domain shop name` , ( ) => {
11+ expect ( createClient ( `my-shop` , `token` ) . url ) . toEqual (
12+ expect . stringContaining ( `myshopify.com` )
13+ )
14+ } )
15+ } )
Original file line number Diff line number Diff line change @@ -2,9 +2,16 @@ import { GraphQLClient } from "graphql-request"
22/**
33 * Create a Shopify Storefront GraphQL client for the provided name and token.
44 */
5- export const createClient = ( shopName , accessToken ) =>
6- new GraphQLClient ( `https://${ shopName } .myshopify.com/api/graphql` , {
5+ export const createClient = ( shopName , accessToken ) => {
6+ let url
7+ if ( shopName . includes ( `.` ) ) {
8+ url = `https://${ shopName } /api/graphql`
9+ } else {
10+ url = `https://${ shopName } .myshopify.com/api/graphql`
11+ }
12+ return new GraphQLClient ( url , {
713 headers : {
814 "X-Shopify-Storefront-Access-Token" : accessToken ,
915 } ,
1016 } )
17+ }
You can’t perform that action at this time.
0 commit comments