graphql-extensions
Advanced tools
Comparing version 0.1.0-beta.4 to 0.1.0-beta.5
import { GraphQLSchema, GraphQLField, GraphQLResolveInfo, ExecutionArgs } from 'graphql'; | ||
export declare type EndHandler = () => void; | ||
export declare type EndHandler = (err: Error | null) => void; | ||
export declare class GraphQLExtension<TContext = any> { | ||
@@ -7,3 +7,5 @@ requestDidStart?(o: { | ||
}): EndHandler | void; | ||
parsingDidStart?(): EndHandler | void; | ||
parsingDidStart?(o: { | ||
queryString: string; | ||
}): EndHandler | void; | ||
validationDidStart?(): EndHandler | void; | ||
@@ -24,3 +26,5 @@ executionDidStart?(o: { | ||
}): EndHandler; | ||
parsingDidStart(): EndHandler; | ||
parsingDidStart(o: { | ||
queryString: string; | ||
}): EndHandler; | ||
validationDidStart(): EndHandler; | ||
@@ -27,0 +31,0 @@ executionDidStart(o: { |
@@ -17,4 +17,4 @@ "use strict"; | ||
}; | ||
GraphQLExtensionStack.prototype.parsingDidStart = function () { | ||
return this.handleDidStart(function (ext) { return ext.parsingDidStart && ext.parsingDidStart(); }); | ||
GraphQLExtensionStack.prototype.parsingDidStart = function (o) { | ||
return this.handleDidStart(function (ext) { return ext.parsingDidStart && ext.parsingDidStart(o); }); | ||
}; | ||
@@ -59,3 +59,3 @@ GraphQLExtensionStack.prototype.validationDidStart = function () { | ||
}); | ||
return function () { | ||
return function (err) { | ||
// We run end handlers in reverse order of start handlers. That way, the | ||
@@ -65,3 +65,3 @@ // first handler in the stack "surrounds" the entire event's process | ||
endHandlers.reverse(); | ||
endHandlers.forEach(function (endHandler) { return endHandler(); }); | ||
endHandlers.forEach(function (endHandler) { return endHandler(err); }); | ||
}; | ||
@@ -68,0 +68,0 @@ }; |
{ | ||
"name": "graphql-extensions", | ||
"version": "0.1.0-beta.4", | ||
"version": "0.1.0-beta.5", | ||
"description": "Add extensions to GraphQL servers", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -11,3 +11,3 @@ import { | ||
export type EndHandler = () => void; | ||
export type EndHandler = (err: Error | null) => void; | ||
type StartHandler = () => EndHandler | void; | ||
@@ -22,6 +22,8 @@ // A StartHandlerInvoker is a function that, given a specific GraphQLExtension, | ||
export class GraphQLExtension<TContext = any> { | ||
public requestDidStart?(o: {request: Request}): EndHandler | void; | ||
public parsingDidStart?(): EndHandler | void; | ||
public requestDidStart?(o: { request: Request }): EndHandler | void; | ||
public parsingDidStart?(o: { queryString: string }): EndHandler | void; | ||
public validationDidStart?(): EndHandler | void; | ||
public executionDidStart?(o: {executionArgs: ExecutionArgs}): EndHandler | void; | ||
public executionDidStart?(o: { | ||
executionArgs: ExecutionArgs; | ||
}): EndHandler | void; | ||
@@ -45,13 +47,21 @@ public willResolveField?( | ||
public requestDidStart(o: {request: Request}): EndHandler { | ||
return this.handleDidStart(ext => ext.requestDidStart && ext.requestDidStart(o)); | ||
public requestDidStart(o: { request: Request }): EndHandler { | ||
return this.handleDidStart( | ||
ext => ext.requestDidStart && ext.requestDidStart(o), | ||
); | ||
} | ||
public parsingDidStart(): EndHandler { | ||
return this.handleDidStart(ext => ext.parsingDidStart && ext.parsingDidStart()); | ||
public parsingDidStart(o: { queryString: string }): EndHandler { | ||
return this.handleDidStart( | ||
ext => ext.parsingDidStart && ext.parsingDidStart(o), | ||
); | ||
} | ||
public validationDidStart(): EndHandler { | ||
return this.handleDidStart(ext => ext.validationDidStart && ext.validationDidStart()); | ||
return this.handleDidStart( | ||
ext => ext.validationDidStart && ext.validationDidStart(), | ||
); | ||
} | ||
public executionDidStart(o: {executionArgs: ExecutionArgs}): EndHandler { | ||
return this.handleDidStart(ext => ext.executionDidStart && ext.executionDidStart(o)); | ||
public executionDidStart(o: { executionArgs: ExecutionArgs }): EndHandler { | ||
return this.handleDidStart( | ||
ext => ext.executionDidStart && ext.executionDidStart(o), | ||
); | ||
} | ||
@@ -98,3 +108,3 @@ | ||
}); | ||
return () => { | ||
return (err: Error | null) => { | ||
// We run end handlers in reverse order of start handlers. That way, the | ||
@@ -104,3 +114,3 @@ // first handler in the stack "surrounds" the entire event's process | ||
endHandlers.reverse(); | ||
endHandlers.forEach(endHandler => endHandler()); | ||
endHandlers.forEach(endHandler => endHandler(err)); | ||
}; | ||
@@ -107,0 +117,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24126
478