All Projects → withspectrum → Graphql Log

withspectrum / Graphql Log

Licence: mit
Add logging to your GraphQL resolvers so you know what's going on in your app.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Graphql Log

Graphql2rest
GraphQL to REST converter: automatically generate a RESTful API from your existing GraphQL API
Stars: ✭ 181 (+92.55%)
Mutual labels:  graphql, graphql-server, graphql-js, graphql-schema
Graphql Cost Analysis
A Graphql query cost analyzer.
Stars: ✭ 527 (+460.64%)
Mutual labels:  graphql, graphql-server, graphql-js, graphql-schema
Typegql
Create GraphQL schema with TypeScript classes.
Stars: ✭ 415 (+341.49%)
Mutual labels:  graphql, graphql-server, graphql-js, graphql-schema
Gramps Legacy
The core data source combination engine of GrAMPS.
Stars: ✭ 198 (+110.64%)
Mutual labels:  graphql, graphql-server, apollographql, graphql-schema
Apollo Server
🌍  Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
Stars: ✭ 12,145 (+12820.21%)
Mutual labels:  graphql, graphql-server, apollographql, graphql-schema
36 Graphql Concepts
📜 36 concepts every GraphQL developer should know.
Stars: ✭ 209 (+122.34%)
Mutual labels:  graphql, graphql-server, graphql-schema
graphql-express-nodejs
A Simple GraphQL Server implementation using Express and Node. See post here: https://t.co/Cm6GitZaBL
Stars: ✭ 24 (-74.47%)
Mutual labels:  graphql-server, graphql-schema, graphql-js
Data Source Base
Boilerplate for creating a GrAMPS-compatible data source.
Stars: ✭ 52 (-44.68%)
Mutual labels:  graphql, graphql-server, apollographql
Graphql To Mongodb
Allows for generic run-time generation of filter types for existing graphql types and parsing client requests to mongodb find queries
Stars: ✭ 261 (+177.66%)
Mutual labels:  graphql, graphql-server, graphql-js
relay-compiler-plus
Custom relay compiler which supports persisted queries
Stars: ✭ 68 (-27.66%)
Mutual labels:  graphql-server, graphql-schema, graphql-js
Graphql Up
Get a ready-to-use GraphQL API for your schema
Stars: ✭ 415 (+341.49%)
Mutual labels:  graphql, graphql-server, apollographql
Get Graphql Schema
Fetch and print the GraphQL schema from a GraphQL HTTP endpoint. (Can be used for Relay Modern.)
Stars: ✭ 443 (+371.28%)
Mutual labels:  graphql, apollographql, graphql-schema
Type Graphql
Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
Stars: ✭ 6,864 (+7202.13%)
Mutual labels:  graphql, graphql-js, graphql-schema
Grial
A Node.js framework for creating GraphQL API servers easily and without a lot of boilerplate.
Stars: ✭ 194 (+106.38%)
Mutual labels:  graphql, graphql-server, graphql-js
graphql-spotify
GraphQL Schema And Resolvers For Spotify Web API
Stars: ✭ 55 (-41.49%)
Mutual labels:  graphql-server, graphql-schema, graphql-js
Hotchocolate
Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
Stars: ✭ 3,009 (+3101.06%)
Mutual labels:  graphql, graphql-server, graphql-schema
Hangzhou Graphql Party
杭州 GraphQLParty 往期记录(slide,照片,预告,视频等)
Stars: ✭ 142 (+51.06%)
Mutual labels:  graphql, graphql-server, graphql-js
Fullstack Graphql
🌈 Simple Fullstack GraphQL Application. API built with Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with React + Redux to access the API. Written in ES6 using Babel + Webpack.
Stars: ✭ 955 (+915.96%)
Mutual labels:  graphql, graphql-server, graphql-schema
Graphql Tools
🔧 Build, mock, and stitch a GraphQL schema using the schema language
Stars: ✭ 4,556 (+4746.81%)
Mutual labels:  graphql, graphql-js, graphql-schema
Strawberry
A new GraphQL library for Python 🍓
Stars: ✭ 891 (+847.87%)
Mutual labels:  graphql, graphql-server, graphql-schema

graphql-log

Add logging to your GraphQL resolvers so you know what's going on in your app.

Everytime a resolver is executed it logs the full path to the resolver. The output in your terminal (when using the popular debug module for logging) will be something like this:

server:resolvers Message.channel +0ms
server:resolvers User.avatar +0ms
server:resolvers User.username +0ms
server:resolvers User.avatar +4ms
server:resolvers User.coverPhoto +0ms
server:resolvers User.username +0ms

Note: The "server:resolvers" and "+xms" parts are added by debug, this module only logs the path on execution.

Usage

This is the simplest example:

// Require the module
const createGraphQLLogger = require('graphql-log');

// Create a logger
const logExecutions = createGraphQLLogger();

// Wrap your resolvers
logExecutions(resolvers);

Note that your resolvers need to be a plain object of resolvers. (like you'd create for graphql-tools makeExecutableSchema function)

Options

graphql-log has some options:

  • logger (function, default: console.log): Use a custom logger like debug, pino or any other one.
  • prefix (string): Prefix all logs with a certain string
const logExecutions = createGraphQLLogger({
  // Prefix all logs with resolvers.
  prefix: 'resolvers.',
});

Usage with custom loggers

Let's say you want to use the popular debug module for logging. Doing so would be as easy as passing it into the logger option:

const debug = require('debug')('server:resolvers');

const logExecutions = createGraphQLLogger({
  logger: debug,
});

Usage only in development

Logging every execution of every resolver will have a performance impact on your app, so we recommend only enabling this module in development. A common way to do so (depending on your setup) would be something like this:

const createGraphQLLogger = require('graphql-log');

const resolvers = {/*...*/};

if (process.env.NODE_ENV === 'development') {
  const logExecutions = createGraphQLLogger();
  logExecutions(resolvers);
}

Roadmap

The main thing I want to change is that instead of wrapping the resolvers this module would wrap a finished schema instead. This would make it compatible not only with folks who keep their resolvers separate, but with everybody.

That'd probably look something like this:

// I'd love to be able to pass a schema
logExecutions(schema);

Good first PR?

License

Licensed under the MIT License, Copyright ©️ 2017 Maximilian Stoiber. See LICENSE.md for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].