apollo-server-core
Advanced tools
Comparing version 1.1.7 to 1.2.0-pre.1
@@ -15,2 +15,3 @@ import { GraphQLSchema, ValidationContext, GraphQLFieldResolver } from 'graphql'; | ||
tracing?: boolean; | ||
cacheControl?: boolean; | ||
} | ||
@@ -17,0 +18,0 @@ export default GraphQLServerOptions; |
@@ -153,2 +153,3 @@ "use strict"; | ||
tracing: optionsObject.tracing, | ||
cacheControl: optionsObject.cacheControl, | ||
}; | ||
@@ -155,0 +156,0 @@ if (optionsObject.formatParams) { |
@@ -43,4 +43,5 @@ import { GraphQLSchema, GraphQLFieldResolver, DocumentNode, GraphQLError, ValidationContext } from 'graphql'; | ||
tracing?: boolean; | ||
cacheControl?: boolean; | ||
} | ||
declare function runQuery(options: QueryOptions): Promise<GraphQLResponse>; | ||
export { runQuery }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var graphql_1 = require("graphql"); | ||
var graphql_extensions_1 = require("graphql-extensions"); | ||
var apollo_tracing_1 = require("apollo-tracing"); | ||
var apollo_cache_control_1 = require("apollo-cache-control"); | ||
var LogAction; | ||
@@ -30,9 +32,15 @@ (function (LogAction) { | ||
var context = options.context || {}; | ||
var traceCollector; | ||
var extensions = []; | ||
if (options.tracing) { | ||
traceCollector = new apollo_tracing_1.TraceCollector(); | ||
context._traceCollector = traceCollector; | ||
traceCollector.requestDidStart(); | ||
apollo_tracing_1.instrumentSchemaForTracing(options.schema); | ||
extensions.push(apollo_tracing_1.TracingExtension); | ||
} | ||
if (options.cacheControl) { | ||
extensions.push(apollo_cache_control_1.CacheControlExtension); | ||
} | ||
var extensionStack = extensions.length > 0 && new graphql_extensions_1.GraphQLExtensionStack(extensions); | ||
if (extensionStack) { | ||
context._extensionStack = extensionStack; | ||
graphql_extensions_1.enableGraphQLExtensions(options.schema); | ||
extensionStack.requestDidStart(); | ||
} | ||
function format(errors) { | ||
@@ -86,4 +94,4 @@ return errors.map(function (error) { | ||
} | ||
if (traceCollector) { | ||
traceCollector.executionDidStart(); | ||
if (extensionStack) { | ||
extensionStack.executionDidStart(); | ||
} | ||
@@ -104,7 +112,6 @@ try { | ||
} | ||
if (traceCollector) { | ||
traceCollector.requestDidEnd(); | ||
response.extensions = { | ||
'tracing': apollo_tracing_1.formatTraceData(traceCollector), | ||
}; | ||
if (extensionStack) { | ||
extensionStack.executionDidEnd(); | ||
extensionStack.requestDidEnd(); | ||
response.extensions = extensionStack.format(); | ||
} | ||
@@ -111,0 +118,0 @@ if (options.formatResponse) { |
{ | ||
"name": "apollo-server-core", | ||
"version": "1.1.7", | ||
"version": "1.2.0-pre.1", | ||
"description": "Core engine for Apollo GraphQL server", | ||
@@ -8,2 +8,3 @@ "main": "dist/index.js", | ||
"compile": "tsc", | ||
"watch": "tsc -w", | ||
"prepublish": "npm run compile" | ||
@@ -31,3 +32,4 @@ }, | ||
"fibers": "1.0.15", | ||
"meteor-promise": "0.8.6" | ||
"meteor-promise": "0.8.6", | ||
"typescript": "^2.5.3" | ||
}, | ||
@@ -42,4 +44,6 @@ "peerDependencies": { | ||
"dependencies": { | ||
"apollo-tracing": "^0.0.x" | ||
"apollo-cache-control": "^0.0.x", | ||
"apollo-tracing": "^0.1.0", | ||
"graphql-extensions": "^0.0.x" | ||
} | ||
} |
import { GraphQLSchema, ValidationContext, GraphQLFieldResolver } from 'graphql'; | ||
import { LogFunction } from './runQuery'; | ||
import { GraphQLExtension } from 'graphql-extensions'; | ||
@@ -31,2 +32,3 @@ /* | ||
tracing?: boolean; | ||
cacheControl?: boolean; | ||
} | ||
@@ -33,0 +35,0 @@ |
@@ -122,2 +122,3 @@ import { parse, getOperationAST, DocumentNode, formatError, ExecutionResult } from 'graphql'; | ||
tracing: optionsObject.tracing, | ||
cacheControl: optionsObject.cacheControl, | ||
}; | ||
@@ -124,0 +125,0 @@ |
@@ -16,7 +16,5 @@ import { | ||
import { | ||
TraceCollector, | ||
instrumentSchemaForTracing, | ||
formatTraceData, | ||
} from 'apollo-tracing'; | ||
import { enableGraphQLExtensions, GraphQLExtension, GraphQLExtensionStack } from 'graphql-extensions'; | ||
import { TracingExtension } from 'apollo-tracing'; | ||
import { CacheControlExtension } from 'apollo-cache-control'; | ||
@@ -65,2 +63,3 @@ export interface GraphQLResponse { | ||
tracing?: boolean; | ||
cacheControl?: boolean; | ||
} | ||
@@ -85,11 +84,18 @@ | ||
const context = options.context || {}; | ||
let traceCollector: TraceCollector; | ||
let extensions = []; | ||
if (options.tracing) { | ||
traceCollector = new TraceCollector(); | ||
context._traceCollector = traceCollector; | ||
traceCollector.requestDidStart(); | ||
instrumentSchemaForTracing(options.schema); | ||
extensions.push(TracingExtension); | ||
} | ||
if (options.cacheControl) { | ||
extensions.push(CacheControlExtension); | ||
} | ||
const extensionStack = extensions.length > 0 && new GraphQLExtensionStack(extensions); | ||
if (extensionStack) { | ||
context._extensionStack = extensionStack; | ||
enableGraphQLExtensions(options.schema); | ||
extensionStack.requestDidStart(); | ||
} | ||
function format(errors: Array<Error>): Array<Error> { | ||
@@ -146,4 +152,4 @@ return errors.map((error) => { | ||
if (traceCollector) { | ||
traceCollector.executionDidStart(); | ||
if (extensionStack) { | ||
extensionStack.executionDidStart(); | ||
} | ||
@@ -176,7 +182,6 @@ | ||
if (traceCollector) { | ||
traceCollector.requestDidEnd(); | ||
response.extensions = { | ||
'tracing': formatTraceData(traceCollector), | ||
}; | ||
if (extensionStack) { | ||
extensionStack.executionDidEnd(); | ||
extensionStack.requestDidEnd(); | ||
response.extensions = extensionStack.format(); | ||
} | ||
@@ -183,0 +188,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
56742
1117
4
5
1
+ Addedapollo-cache-control@^0.0.x
+ Addedgraphql-extensions@^0.0.x
+ Addedapollo-cache-control@0.0.10(transitive)
+ Addedapollo-tracing@0.1.4(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedgraphql-extensions@0.0.10(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
- Removed@wry/equality@0.1.11(transitive)
- Removedapollo-link@1.2.14(transitive)
- Removedapollo-tracing@0.0.9(transitive)
- Removedapollo-utilities@1.3.4(transitive)
- Removeddeprecated-decorator@0.1.6(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedgraphql-tools@2.24.0(transitive)
- Removedts-invariant@0.4.4(transitive)
- Removedtslib@1.14.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedzen-observable@0.8.15(transitive)
- Removedzen-observable-ts@0.8.21(transitive)
Updatedapollo-tracing@^0.1.0