Skip to content

Commit

Permalink
feat(gatsby): invite people with long page query running to try out q…
Browse files Browse the repository at this point in the history
…uery on demand feature (#28181)
  • Loading branch information
pieh authored Nov 19, 2020
1 parent bbfc6de commit 413888b
Showing 1 changed file with 35 additions and 0 deletions.
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()
}

0 comments on commit 413888b

Please sign in to comment.