-
Notifications
You must be signed in to change notification settings - Fork 538
Conversation
@williambailey Thanks for PR 👍
You don't need async since options callback can return promise of options: graphqlHTTP(graphqlHTTPOptions);
function graphqlHTTPOptions(request, response, params) {
return getASTFromCache(params.query).then(ast => {
schema,
customParseFn() {
return ast;
}
})
} Every time you add Note: you also get
|
Completely forgot that you could return a promise of options. PR updated. |
src/index.js
Outdated
@@ -265,11 +272,11 @@ function graphqlHTTP(options: Options): Middleware { | |||
} | |||
|
|||
// GraphQL source. | |||
const source = new Source(query, 'GraphQL request'); | |||
const source = new Source(query); |
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.
@williambailey Can you please revert this line?
@williambailey Thanks 👍 |
@williambailey Sorry for delay. I just published |
* Add support for customParseFn option * Update README.md * Make customParseFn have the same signature as parse()
Attempt to address #483.
The current implementation in this PR provides support for synchronous
customParseFn
functions.Eventually I think that it would be worthwhile also supporting asynchronous functions. i.e. have the
customParseFn
return type be a (let's see if i get the Flow type correct)?Promise<DocumentNode>
. Unfortunitely I couldn't quite get the promise handling.then().catch()
logic right at this point in time... even when requiring thecustomParseFn
be async (vs. maybe async).