
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
apollo-request-tracer
Advanced tools
Extension for tracing GraphQL query resolution in ApolloServer
Primary motivation of this lib is tracking cold and warm start performance of GraphQL in serverless environments (AWS Lambda, Google Cloud Functions)
yarn add apollo-request-tracer@1.0.2
// Create a new tracer
const Tracer = require('apollo-request-tracer');
const tracer = Tracer.start();
// Create a timer tracking how long node module import takes
let requireTimer = tracer.time('module_requires');
const Express = require('Express');
const {ApolloServer, gql} = require('apollo-server-express');
const Functions = require('firebase-functions');
const Models = require('./Models');
// Stop the timer
requireTimer.stop();
// Create a timer tracking how long the initial GraphQL setup takes
let setupTimer = tracer.time('graphql_setup');
const typeDefs = gql`
type Query {
hello(name: String): String
}
`;
const resolvers = {
Query: {
hello: async (args, context)=> {
// Request tracer gets added to resolver context and can be used
// for adding timing information specific to that resolver
const {tracer} = context;
const timer = tracer.time('build_hello_message');
const message = `Hello ${args.name}!`;
timer.stop();
return message;
}
}
};
// Create a new ApolloServer with tracer extension that tracks
// the graphql query resolution process
const server = new ApolloServer({
typeDefs,
resolvers,
extensions: [tracer.request]
});
const app = Express();
server.applyMiddleware({app, path: '/'});
module.exports = {
graphql: Functions.https.onRequest(app);
};
// Stop setup timer and tracer
setupTimer.stop();
tracer.stop();
FAQs
Request tracing for Apollo Server
The npm package apollo-request-tracer receives a total of 0 weekly downloads. As such, apollo-request-tracer popularity was classified as not popular.
We found that apollo-request-tracer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.