Skip to content

brianhip/kensats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KensaTS

A lightweight package to gather metrics from your GraphQL Apollo Server queries.

Getting Started

To be able to test your GraphQL application install our package following these instructions.

Note: Currently supporting GraphQL Apollo Server only.

Prerequisites

You need to have a backend server built using GraphQL Apollo Server. Go to the GraphQL to learn more about using GraphQL with Apollo Server.

Have an account with Kensa. Visit Kensa and sign up for an account to get full access to the Kensa web app.


Installing

Install the KensaTS Package into your project

npm install kensats

In your server file, import the following plugins from kensats:

import { kensaPlugin, getContext} from 'kensats';

Include the kensaPlugin in your plugins array
  const apolloServer = new ApolloServer({
    typeDefs,
    resolvers,
    plugins: [kensaPlugin]
  }); 

Get the API key from the project you are going to be testing by clicking on the info button.

And paste it on your server file

 const api = '65b00bbe-3b3b-4fea-8d3f-de3a84338914';

Set the required context by calling the function getContext and passing the request and response objects inside an object and the api key as second argument. Optionally you can also pass your test database. The expressMiddleware function enables you to attach Apollo Server to an Express server.
  app.use('/graphql', cors(), bodyParser.json(), expressMiddleware(apolloServer, {
    // when referencing the database in resolvers, use 'db' when deconstructing context object
    context: async ({req, res}: any) => (await getContext({req, res}, api, testDb))
  }));

Authors

  • Brian Peinado
  • Tommy Li
  • Brian Pham
  • Raymond Kim

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors