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

feat(gatsby): invite people with long page query running to try out query on demand feature #28181

Merged
Merged
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
35 changes: 35 additions & 0 deletions packages/gatsby/src/services/run-page-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { processPageQueries } from "../query"
import reporter from "gatsby-cli/lib/reporter"
import { IQueryRunningContext } from "../state-machines/query-running/types"
import { assertStore } from "../utils/assert-store"
import {
showExperimentNoticeAfterTimeout,
CancelExperimentNoticeCallbackOrUndefined,
} from "../utils/show-experiment-notice"
import { isCI } from "gatsby-core-utils"

const TWO_MINUTES = 2 * 60 * 1000

export async function runPageQueries({
parentSpan,
Expand Down Expand Up @@ -35,12 +42,40 @@ export async function runPageQueries({
)

activity.start()

let cancelNotice: CancelExperimentNoticeCallbackOrUndefined
if (
process.env.gatsby_executing_command === `develop` &&
!process.env.GATSBY_EXPERIMENTAL_QUERY_ON_DEMAND &&
!isCI()
) {
cancelNotice = showExperimentNoticeAfterTimeout(
`queryOnDemand`,
reporter.stripIndent(`
Your local development experience is about to get better, faster, and stronger!

Your friendly Gatsby maintainers detected your site takes longer than ideal to run page queries. We're working right now to improve this.

If you're interested in trialing out one of these future improvements *today* which should make your local development experience faster, go ahead and run your site with QUERY_ON_DEMAND enabled.

GATSBY_EXPERIMENTAL_QUERY_ON_DEMAND=true gatsby develop

Please do let us know how it goes (good, bad, or otherwise) and learn more about it at https://gatsby.dev/query-on-demand-feedback
`),
TWO_MINUTES
)
}

await processPageQueries(pageQueryIds, {
state,
activity,
graphqlRunner,
graphqlTracing: program?.graphqlTracing,
})

if (cancelNotice) {
cancelNotice()
}

activity.done()
}