graphql-extensions
Advanced tools
Comparing version 0.1.0-beta.0 to 0.1.0-beta.1
@@ -5,7 +5,7 @@ # Changelog | ||
### 0.1.0-beta.0 | ||
### 0.1.0-beta | ||
- *Backwards-incompatible change*: `fooDidStart` handlers (where foo is `request`, `parsing`, `validation`, and `execution`) now return their end handler; the `fooDidEnd` handlers no longer exist. | ||
- *Backwards-incompatible change*: Only `GraphQLExtension` objects may be passed to the `GraphQLExtensionStack` constructor, not their constructors. | ||
- *Backwards-incompatible change*: Previously, the `GraphQLExtensionStack` constructor took either `GraphQLExtension` objects or their constructors. You may still pass in `GraphQLExtension` objects, but if functions are provided, they are treated as non-constructor functions which take in a new `GraphQLExtensionOptions` options type as an argument. | ||
### 0.0.10 | ||
- Fix lifecycle method invocations on extensions |
@@ -1,3 +0,6 @@ | ||
import { GraphQLSchema, GraphQLField, GraphQLResolveInfo } from 'graphql'; | ||
import { GraphQLSchema, GraphQLField, GraphQLResolveInfo, ExecutionArgs } from 'graphql'; | ||
export declare type EndHandler = () => void; | ||
export interface GraphQLExtensionOptions { | ||
executionArgs: ExecutionArgs; | ||
} | ||
export declare class GraphQLExtension<TContext = any> { | ||
@@ -15,3 +18,3 @@ requestDidStart?(): EndHandler | void; | ||
private extensions; | ||
constructor(extensions: GraphQLExtension<TContext>[]); | ||
constructor(extensions: (((o: GraphQLExtensionOptions) => GraphQLExtension<TContext>) | GraphQLExtension<TContext>)[], options: GraphQLExtensionOptions); | ||
requestDidStart(): (() => void); | ||
@@ -18,0 +21,0 @@ parsingDidStart(): (() => void); |
@@ -11,4 +11,8 @@ "use strict"; | ||
var GraphQLExtensionStack = /** @class */ (function () { | ||
function GraphQLExtensionStack(extensions) { | ||
this.extensions = extensions; | ||
function GraphQLExtensionStack(extensions, options) { | ||
this.extensions = extensions.map(function (extensionOrFactory) { | ||
return typeof extensionOrFactory === 'function' | ||
? extensionOrFactory(options) | ||
: extensionOrFactory; | ||
}); | ||
} | ||
@@ -15,0 +19,0 @@ GraphQLExtensionStack.prototype.requestDidStart = function () { |
{ | ||
"name": "graphql-extensions", | ||
"version": "0.1.0-beta.0", | ||
"version": "0.1.0-beta.1", | ||
"description": "Add extensions to GraphQL servers", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -8,2 +8,3 @@ import { | ||
GraphQLResolveInfo, | ||
ExecutionArgs, | ||
} from 'graphql'; | ||
@@ -17,2 +18,7 @@ | ||
export interface GraphQLExtensionOptions { | ||
executionArgs: ExecutionArgs; | ||
// XXX Will add a W3C-style Request here later | ||
} | ||
export class GraphQLExtension<TContext = any> { | ||
@@ -37,4 +43,14 @@ public requestDidStart?(): EndHandler | void; | ||
constructor(extensions: GraphQLExtension<TContext>[]) { | ||
this.extensions = extensions; | ||
constructor( | ||
extensions: ( | ||
| ((o: GraphQLExtensionOptions) => GraphQLExtension<TContext>) | ||
| GraphQLExtension<TContext>)[], | ||
options: GraphQLExtensionOptions, | ||
) { | ||
this.extensions = extensions.map( | ||
extensionOrFactory => | ||
typeof extensionOrFactory === 'function' | ||
? extensionOrFactory(options) | ||
: extensionOrFactory, | ||
); | ||
} | ||
@@ -41,0 +57,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
24053
478