-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Execute queries in Fibers to support yielding APIs. #92
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,19 @@ export interface QueryOptions { | |
formatResponse?: Function; | ||
} | ||
|
||
// Make the global Promise constructor Fiber-aware. | ||
import { makeCompatible } from 'meteor-promise'; | ||
import Fiber = require('fibers'); | ||
makeCompatible(Promise, Fiber); | ||
|
||
const resolvedPromise = Promise.resolve(); | ||
|
||
function runQuery(options: QueryOptions): Promise<GraphQLResult> { | ||
// Fiber-aware Promises run their .then callbacks in Fibers. | ||
return resolvedPromise.then(() => doRunQuery(options)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having this in apollo-server core is probably OK, because it's not specific to fibers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I think this may be the key to making everything work in Meteor, since the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can confirm this change is necessary and sufficient to accommodate Meteor developers who want to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Amazing! |
||
} | ||
|
||
function doRunQuery(options: QueryOptions): Promise<GraphQLResult> { | ||
let documentAST: Document; | ||
|
||
const logFunction = options.logFunction || function(){ return null; }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to move these four lines either to the meteor-integration package or Meteor itself?