graphql-perf
v0.0.1
Published
Gather performance information from GraphQL resolve methods and prepare JSON in Trace Event Format for Chrome Devtools Timeline
Downloads
2
Maintainers
Readme
graphql-perf
Gather performance information from GraphQL resolve
methods and prepare JSON in Trace Event Format for Chrome Devtools Timeline.
Current plans/aims/thoughts
- VIEW: responsive timeline graphics in Google Chrome Devtools
- just click a link in browser console or press a button in extension
- you will measure only current request
- no need to setup special server or buy a subscription, eg. Apollo Optics
- if you need aggregated statistics use Apollo Optics 😉
- SERVER: should work with any GraphQL Schema under nodejs
- but if schema built with https://github.com/nodkz/graphql-compose-mongoose (and other
graphql-compose
libs) will have additional profiling info - should have api that allows other libs to provide extended perf metrics
- will integrate it with
express-graphql
- but also may be integrated with
apollo-server
and others
- but if schema built with https://github.com/nodkz/graphql-compose-mongoose (and other
- CLIENT: should have link, button, extension that open Devtools Timeline
- perf data will be in the json-response from graphql server under
extensions.perf
path in it. - will integrate it with https://github.com/nodkz/react-relay-network-layer
- so needs help in passing this data to Devtools Timeline (some link or chrome extension) or some another way.
- perf data will be in the json-response from graphql server under
- OTHER SERVERS:
- maybe somebody writes for other languages similar perf export in Trace Event Format under extensions.perf path in graphql response.
I'll try to start it at the end of November/December. Too much work right now.
Did you have experience with Trace Event Format? Or maybe want help? Or start to develop such thing right now? Or maybe can recommend additional sources/articles? Feel free to open issue. Will be glad to any help and thoughts.
How it should work under the hood
This package should traverse by types and fields (of provided GraphQL Schema instance) wraps all resolvers and return new wrapped Schema in build phase (when nodejs starts your server). After that for every request, when server gets ?perf=1
param (or some other key in headers) it will pass wrapped schema to graphql-express, otherwise for regular users your initial schema for performance reasons. It will be safe to use it in production, without losing performance.
Gathered trace information should be written to the GraphQL response extensions.perf
key in the Trace Event Format.
Useful links
- [RFC] Trace Event Format
- [Article] In-depth: Using Chrome://tracing to view your inline profiling data
- [Repo:Client] Chrome devtools extension to generate a URL for your timeline
- [Repo:Competitor] Trace collection library for GraphQL servers from Apollostack
Cybersquatting
I'm reserved graphql-perf
name in npmjs, cause think that only such module may have so brave name. 😉
PS. I with pleasure free this name, if somebody made the same module or even better, until I began to develop.