Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gatsby-source-shopify Update API version to 2019 07 #20612

Merged
merged 3 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/gatsby-source-shopify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ plugins: [
// See: https://help.shopify.com/api/custom-storefronts/storefront-api/getting-started#authentication
accessToken: "example-wou7evoh0eexuf6chooz2jai2qui9pae4tieph1sei4deiboj",

// Set the API version you want to use. For a list of available API versions,
// see: https://help.shopify.com/en/api/storefront-api/reference/queryroot
// Defaults to 2019-07
apiVersion: "2020-01",

// Set verbose to true to display a verbose output on `npm run develop`
// or `npm run build`. This prints which nodes are being fetched and how
// much time was required to fetch and process the data.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"shop":{"articles":{"pageInfo":{"hasNextPage":false},"edges":[]}}}
{"articles":{"pageInfo":{"hasNextPage":false},"edges":[]}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"shop":{"blogs":{"pageInfo":{"hasNextPage":false},"edges":[{"cursor":"eyJsYXN0X2lkIjoxMjcyMzQ4Njk3LCJsYXN0X3ZhbHVlIjoiMTI3MjM0ODY5NyJ9","node":{"id":"Z2lkOi8vc2hvcGlmeS9CbG9nLzEyNzIzNDg2OTc=","title":"News","url":"https://gatsby-swag.myshopify.com/blogs/news"}}]}}}
{"blogs":{"pageInfo":{"hasNextPage":false},"edges":[{"cursor":"eyJsYXN0X2lkIjoxMjcyMzQ4Njk3LCJsYXN0X3ZhbHVlIjoiMTI3MjM0ODY5NyJ9","node":{"id":"Z2lkOi8vc2hvcGlmeS9CbG9nLzEyNzIzNDg2OTc=","title":"News","url":"https://gatsby-swag.myshopify.com/blogs/news"}}]}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"shop":{"collections":{"pageInfo":{"hasNextPage":false},"edges":[{"cursor":"eyJsYXN0X2lkIjo3MDU0MDAwMTUzLCJsYXN0X3ZhbHVlIjoiNzA1NDAwMDE1MyJ9","node":{"description":"","descriptionHtml":"","handle":"frontpage","id":"Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzcwNTQwMDAxNTM=","image":null,"products":{"edges":[{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIzOTczOTk5NDEzNw=="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc2NDkxNDY2MzUxMg=="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzEzMTIxMjA1Njk5NDQ="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc2NzAyMjQ5Nzg4MA=="}}]},"title":"Home page","updatedAt":"2019-08-09T07:35:01Z"}},{"cursor":"eyJsYXN0X2lkIjozMzc3NTc0NzE2MCwibGFzdF92YWx1ZSI6IjMzNzc1NzQ3MTYwIn0=","node":{"description":"The items in this collection are offered to contributors for free as a token of our appreciate for contributing to Gatsby.","descriptionHtml":"The items in this collection are offered to contributors for free as a token of our appreciate for contributing to Gatsby.","handle":"contributor-swag","id":"Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzMzNzc1NzQ3MTYw","image":null,"products":{"edges":[{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIzOTczOTk5NDEzNw=="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc2NDkxNDY2MzUxMg=="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc2NzAyMjQ5Nzg4MA=="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE0MDMyNTU2NTI0NDA="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE0MDMyNTUyNTkyMjQ="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIwMzY4MjEyMjk2NTY="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzM4MTkwNDIxNzcxMTI="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIwNTg0MDQxNjc3Njg="}}]},"title":"Contributor Swag","updatedAt":"2019-08-09T07:35:01Z"}},{"cursor":"eyJsYXN0X2lkIjo4ODIxNjc2NDUwNCwibGFzdF92YWx1ZSI6Ijg4MjE2NzY0NTA0In0=","node":{"description":"","descriptionHtml":"","handle":"level-2","id":"Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzg4MjE2NzY0NTA0","image":null,"products":{"edges":[{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE5NzQ0MzIyMDI4NDA="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE5MzI2OTUwNzY5NTI="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE5OTI2MzIwNDE1NjA="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE5MzI2OTQ1ODU0MzI="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE5MjM0MTkzNDA4ODg="}}]},"title":"Level 2","updatedAt":"2019-08-08T16:05:04Z"}}]}}}
{"collections":{"pageInfo":{"hasNextPage":false},"edges":[{"cursor":"eyJsYXN0X2lkIjo3MDU0MDAwMTUzLCJsYXN0X3ZhbHVlIjoiNzA1NDAwMDE1MyJ9","node":{"description":"","descriptionHtml":"","handle":"frontpage","id":"Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzcwNTQwMDAxNTM=","image":null,"products":{"edges":[{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIzOTczOTk5NDEzNw=="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc2NDkxNDY2MzUxMg=="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzEzMTIxMjA1Njk5NDQ="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc2NzAyMjQ5Nzg4MA=="}}]},"title":"Home page","updatedAt":"2019-08-09T07:35:01Z"}},{"cursor":"eyJsYXN0X2lkIjozMzc3NTc0NzE2MCwibGFzdF92YWx1ZSI6IjMzNzc1NzQ3MTYwIn0=","node":{"description":"The items in this collection are offered to contributors for free as a token of our appreciate for contributing to Gatsby.","descriptionHtml":"The items in this collection are offered to contributors for free as a token of our appreciate for contributing to Gatsby.","handle":"contributor-swag","id":"Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzMzNzc1NzQ3MTYw","image":null,"products":{"edges":[{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIzOTczOTk5NDEzNw=="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc2NDkxNDY2MzUxMg=="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc2NzAyMjQ5Nzg4MA=="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE0MDMyNTU2NTI0NDA="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE0MDMyNTUyNTkyMjQ="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIwMzY4MjEyMjk2NTY="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzM4MTkwNDIxNzcxMTI="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzIwNTg0MDQxNjc3Njg="}}]},"title":"Contributor Swag","updatedAt":"2019-08-09T07:35:01Z"}},{"cursor":"eyJsYXN0X2lkIjo4ODIxNjc2NDUwNCwibGFzdF92YWx1ZSI6Ijg4MjE2NzY0NTA0In0=","node":{"description":"","descriptionHtml":"","handle":"level-2","id":"Z2lkOi8vc2hvcGlmeS9Db2xsZWN0aW9uLzg4MjE2NzY0NTA0","image":null,"products":{"edges":[{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE5NzQ0MzIyMDI4NDA="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE5MzI2OTUwNzY5NTI="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE5OTI2MzIwNDE1NjA="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE5MzI2OTQ1ODU0MzI="}},{"node":{"id":"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzE5MjM0MTkzNDA4ODg="}}]},"title":"Level 2","updatedAt":"2019-08-08T16:05:04Z"}}]}}

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/gatsby-source-shopify/src/create-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { GraphQLClient } from "graphql-request"
/**
* Create a Shopify Storefront GraphQL client for the provided name and token.
*/
export const createClient = (shopName, accessToken) => {
export const createClient = (shopName, accessToken, apiVersion) => {
let url
if (shopName.includes(`.`)) {
url = `https://${shopName}/api/graphql`
url = `https://${shopName}/api/${apiVersion}/graphql.json`
} else {
url = `https://${shopName}.myshopify.com/api/graphql`
url = `https://${shopName}.myshopify.com/api/${apiVersion}/graphql.json`
}
return new GraphQLClient(url, {
headers: {
Expand Down
5 changes: 3 additions & 2 deletions packages/gatsby-source-shopify/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ export const sourceNodes = async (
{
shopName,
accessToken,
apiVersion = `2019-07`,
verbose = true,
paginationSize = 250,
includeCollections = [SHOP, CONTENT],
}
) => {
const client = createClient(shopName, accessToken)
const client = createClient(shopName, accessToken, apiVersion)

// Convenience function to namespace console messages.
const formatMsg = msg =>
Expand Down Expand Up @@ -153,7 +154,7 @@ const createNodes = async (
await forEach(
await queryAll(
client,
[`shop`, NODE_TO_ENDPOINT_MAPPING[endpoint]],
[NODE_TO_ENDPOINT_MAPPING[endpoint]],
query,
paginationSize
),
Expand Down
Loading