Skip to content

Meta: Ensure API calls vary depending on the repo (WIP) - #5839

Closed
fregante wants to merge 1 commit into
mainfrom
cache-bust-repository-query
Closed

fregante wants to merge 1 commit into
mainfrom
cache-bust-repository-query

Conversation

@fregante

Copy link
Copy Markdown
Member

The fix for the issue above is rather easy: change api.v4’s cacheKey to include the repo as well as its parameters.

However I didn't think about that until I was half-way through this, and thought it was still worth the simplification.

Every single v4 call using repository() (except one) only queried repository(), so it made sense to wrap that into a specific helper instead of having a replaceable repository() { string. This has the nice side effect that we skip some awkward template strings we had to use. Example below

Untested, quick search and replace. Must be reviewed without whitespace.

issues(states: OPEN) {
totalCount
}
const labels = await api.v4repository(`

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First feature first bug found. 😅 I made the same mistake in many places.

Have not reviewed yet.

Suggested change
const labels = await api.v4repository(`
const {labels} = await api.v4repository(`

const {owner, name} = getRepo()!;
const {repository, organization} = await api.v4(`
repository() {
repository(owner: "${owner}", name: "${name}") {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only exception. The solution is not bad.

return `
repository() {
${issueIds.map(id => `
return issueIds.map(id => `

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the nice side effect: no more awkward array map inside template literal

@fregante fregante changed the title Meta: Ensure API calls vary depending on the repo Meta: Ensure API calls vary depending on the repo (WIP) Jul 19, 2022
@fregante

Copy link
Copy Markdown
Member Author

Closing in favor of a more proper solution #5848

@fregante fregante closed this Jul 22, 2022
@fregante
fregante deleted the cache-bust-repository-query branch July 22, 2022 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant