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

Add configuration option for number of objects fetched per request #25

Merged
merged 2 commits into from
Jan 26, 2021
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ plugins: [
apiAccess: {
read_key: ``, // Get this value in Bucket > Settings
},
localMedia: true // Download media locally for gatsby image (optional)
localMedia: true, // Download media locally for gatsby image (optional)
limit: 1000, // The number of Objects to fetch on each request (optional)
}
},
]
Expand Down
2 changes: 1 addition & 1 deletion src/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ module.exports = async ({
bucketSlug,
objectType,
apiAccess,
limit,
preview,
}) => {
const timeLabel = `Fetch Cosmic JS data for (${objectType})`
const axiosHeader = {
headers: { 'Accept-Encoding': 'gzip, deflate' },
}
let objects = []
const limit = 1000
let skip = 0
console.time(timeLabel)
console.log(`Starting to fetch data from Cosmic JS (${objectType})`)
Expand Down
2 changes: 2 additions & 0 deletions src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports.sourceNodes = async (
bucketSlug = '',
objectTypes = [],
apiAccess = {},
limit = 1000,
preview = false,
localMedia = false,
}
Expand Down Expand Up @@ -57,6 +58,7 @@ exports.sourceNodes = async (
bucketSlug,
objectType,
apiAccess,
limit,
preview,
})
)
Expand Down