🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

apollo-tracing

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-tracing - npm Package Compare versions

Comparing version

to
0.1.3

11

package.json
{
"name": "apollo-tracing",
"version": "0.1.1",
"version": "0.1.3",
"description": "Collect and expose trace data for GraphQL requests",

@@ -21,8 +21,9 @@ "main": "./lib/index.js",

"peerDependencies": {
"graphql": "^0.10.0 || ^0.11.0"
"graphql": "^0.10.0 || ^0.11.0 || ^0.12.0"
},
"devDependencies": {
"@types/graphql": "^0.11.4",
"@types/node": "^8.0.32",
"typescript": "^2.5.3"
"@types/graphql": "^0.11.8",
"@types/jest": "^22.0.1",
"@types/node": "^9.3.0",
"typescript": "^2.6.2"
},

@@ -29,0 +30,0 @@ "dependencies": {

# Apollo Tracing (for Node.js)
This package is used to collect and expose trace data in the [Apollo Tracing format](https://github.com/apollographql/apollo-tracing).
This package is used to collect and expose trace data in the [Apollo Tracing](https://github.com/apollographql/apollo-tracing) format.
It relies on instrumenting a GraphQL schema to collect resolver timings, and exposes trace data for an individual request under `extensions` as part of the GraphQL response.
The extension format is work in progress, and we're collaborating with others in the GraphQL community to make it broadly available, and to build awesome tools on top of it.
This data can be consumed by [Apollo Engine](https://www.apollographql.com/engine/) or any other tool to provide visualization and history of field-by-field execution performance.
One use of Apollo Tracing is to add support for [Apollo Optics](https://www.apollodata.com/optics/) to more GraphQL servers.
## Usage

@@ -27,37 +25,2 @@

### `express-graphql`
Using Apollo Tracing with `express-graphql` currently requires more manual configuration:
```javascript
import {
TraceCollector,
instrumentSchemaForTracing,
formatTraceData
} from 'apollo-tracing'
...
app.use('/graphql',
(req, res, next) => {
const traceCollector = new TraceCollector();
traceCollector.requestDidStart();
req._traceCollector = traceCollector;
next();
},
graphqlHTTP(request => ({
schema: instrumentSchemaForTracing(schema),
context: {
_traceCollector: request._traceCollector
},
graphiql: true,
extensions: () => {
const traceCollector = request._traceCollector;
traceCollector.requestDidEnd();
return {
tracing: formatTraceData(traceCollector)
}
}
}))
);
```
> If you are using `express-graphql`, we recommend you switch to Apollo Server. Both `express-graphql` and Apollo Server are based on the [`graphql-js`](https://github.com/graphql/graphql-js) reference implementation, and switching should only require changing a few lines of code.