apollo-server-core
Advanced tools
Comparing version 1.0.2 to 1.0.3-tracing.0
@@ -13,2 +13,3 @@ import { GraphQLSchema, ValidationContext } from 'graphql'; | ||
debug?: boolean; | ||
tracing?: boolean; | ||
} | ||
@@ -15,0 +16,0 @@ export default GraphQLServerOptions; |
@@ -151,2 +151,3 @@ "use strict"; | ||
debug: optionsObject.debug, | ||
tracing: optionsObject.tracing | ||
}; | ||
@@ -153,0 +154,0 @@ if (optionsObject.formatParams) { |
@@ -1,5 +0,6 @@ | ||
import { GraphQLSchema, ExecutionResult, DocumentNode, ValidationContext } from 'graphql'; | ||
import { GraphQLSchema, DocumentNode, GraphQLError, ValidationContext } from 'graphql'; | ||
export interface GqlResponse { | ||
data?: Object; | ||
errors?: Array<string>; | ||
data?: object; | ||
errors?: Array<GraphQLError & object>; | ||
extensions?: object; | ||
} | ||
@@ -40,4 +41,5 @@ export declare enum LogAction { | ||
debug?: boolean; | ||
tracing?: boolean; | ||
} | ||
declare function runQuery(options: QueryOptions): Promise<ExecutionResult>; | ||
declare function runQuery(options: QueryOptions): Promise<GqlResponse>; | ||
export { runQuery }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var graphql_1 = require("graphql"); | ||
var apollo_tracing_1 = require("apollo-tracing"); | ||
var LogAction; | ||
@@ -28,2 +29,9 @@ (function (LogAction) { | ||
logFunction({ action: LogAction.request, step: LogStep.start }); | ||
var traceCollector; | ||
if (options.tracing) { | ||
traceCollector = new apollo_tracing_1.TraceCollector(); | ||
options.context._traceCollector = traceCollector; | ||
traceCollector.requestDidStart(); | ||
apollo_tracing_1.instrumentSchemaForTracing(options.schema); | ||
} | ||
function format(errors) { | ||
@@ -77,16 +85,25 @@ return errors.map(function (error) { | ||
} | ||
if (traceCollector) { | ||
traceCollector.executionDidStart(); | ||
} | ||
try { | ||
logFunction({ action: LogAction.execute, step: LogStep.start }); | ||
return graphql_1.execute(options.schema, documentAST, options.rootValue, options.context, options.variables, options.operationName).then(function (gqlResponse) { | ||
return graphql_1.execute(options.schema, documentAST, options.rootValue, options.context, options.variables, options.operationName).then(function (result) { | ||
logFunction({ action: LogAction.execute, step: LogStep.end }); | ||
logFunction({ action: LogAction.request, step: LogStep.end }); | ||
var response = { | ||
data: gqlResponse.data, | ||
data: result.data, | ||
}; | ||
if (gqlResponse.errors) { | ||
response['errors'] = format(gqlResponse.errors); | ||
if (result.errors) { | ||
response.errors = format(result.errors); | ||
if (debug) { | ||
gqlResponse.errors.map(printStackTrace); | ||
result.errors.map(printStackTrace); | ||
} | ||
} | ||
if (traceCollector) { | ||
traceCollector.requestDidEnd(); | ||
response.extensions = { | ||
'tracing': apollo_tracing_1.formatTraceData(traceCollector) | ||
}; | ||
} | ||
if (options.formatResponse) { | ||
@@ -93,0 +110,0 @@ response = options.formatResponse(response, options); |
{ | ||
"name": "apollo-server-core", | ||
"version": "1.0.2", | ||
"version": "1.0.3-tracing.0", | ||
"description": "Core engine for Apollo GraphQL server", | ||
@@ -41,3 +41,6 @@ "main": "dist/index.js", | ||
"definition": "dist/index.d.ts" | ||
}, | ||
"dependencies": { | ||
"apollo-tracing": "0.0.4" | ||
} | ||
} |
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
32675
460
3
1
+ Addedapollo-tracing@0.0.4
+ Addedapollo-tracing@0.0.4(transitive)
+ Addeddeprecated-decorator@0.1.6(transitive)
+ Addedgraphql-tools@1.2.3(transitive)
+ Addeduuid@3.4.0(transitive)