Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bam.tech/koa-graphiql

Package Overview
Dependencies
Maintainers
7
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bam.tech/koa-graphiql

Koa middleware to display GraphiQL

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
7
Created
Source

koa-graphiql

Koa middleware to display GraphiQL. Designed for Koa 2.

Usage

npm i --save koa-graphiql

Add it to your Koa app. You may want to use router middleware if your app serves more than GraphiQL.

import graphiql from 'koa-graphiql';

router.get('/graphiql', graphiql(async (ctx) => {
  return {
    // String of the base URL of the GraphQL endpoint
    url: '/graphql',

    // String to display in the query panel
    query: 'query Demo($token: String) { viewer(token: $token) { id } }',

    // Object used to populate the "variables" panel
    variables: {
      token: 'eyJhbGciOiJIUzI1NiJ9.YWNjb3VudFtpZGVd.-w3FiHaq5jIFIOzHErgdEQGvXXG6wClBUDFDVgwUyx8'
    },

    // Object to display in the result panel
    result: {
      data: {
        viewer: { id: 'account[ide]' }
      }
    },
  };
}));

Typically, you will want to populate the query, variables, and result fields from data in the Koa context, such as the query parameters or request body. koa-graphiql will do this for you by default.

Keywords

FAQs

Package last updated on 07 Sep 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc