kensats
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i kensats

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

13 kB

Total Files

6

Last publish

Collaborators

  • brianhip