Skip to content

Commit

Permalink
chore(gatsby): refactor into await syntax (#28435)
Browse files Browse the repository at this point in the history
* chore(gatsby): refactor into await syntax

* oh wait
  • Loading branch information
pvdz authored Dec 2, 2020
1 parent 299489c commit 013035b
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions packages/gatsby/src/query/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ const createBuildQueue = (

const queueOptions: BetterQueue.QueueOptions<Task, TaskResult> = {
...createBaseOptions(),
process: ({ job, activity }, callback): void => {
queryRunner(graphqlRunner, job, activity?.span)
.then(result => callback(null, result))
.catch(callback)
async process({ job, activity }, callback): Promise<void> {
try {
const result = await queryRunner(graphqlRunner, job, activity?.span)
callback(null, result)
} catch (e) {
callback(e)
}
},
}
return new Queue(queueOptions)
Expand All @@ -62,20 +65,20 @@ const createDevelopQueue = (getRunner: () => GraphQLRunner): Queue => {
): void => {
cb(null, newTask)
},
process: ({ job: queryJob, activity }, callback): void => {
queryRunner(getRunner(), queryJob, activity?.span).then(
result => {
if (!queryJob.isPage) {
websocketManager.emitStaticQueryData({
result,
id: queryJob.hash,
})
}

callback(null, result)
},
error => callback(error)
)
async process({ job: queryJob, activity }, callback): Promise<void> {
try {
const result = await queryRunner(getRunner(), queryJob, activity?.span)
if (!queryJob.isPage) {
websocketManager.emitStaticQueryData({
result,
id: queryJob.hash,
})
}

callback(null, result)
} catch (e) {
callback(e)
}
},
}

Expand Down

0 comments on commit 013035b

Please sign in to comment.