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

@backstage-community/plugin-graphiql

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backstage-community/plugin-graphiql

Backstage plugin for browsing GraphQL APIs

  • 0.3.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
685
decreased by-66.88%
Maintainers
0
Weekly downloads
 
Created
Source

@backstage-community/plugin-graphiql

This plugin integrates GraphiQL as a tool to browse GraphiQL endpoints inside Backstage.

The purpose of the plugin is to provide a convenient way for developers to try out GraphQL queries in their own environment. By exposing GraphiQL as a plugin instead of a standalone app, it's possible to provide a preconfigured environment for engineers, and also tie into authentication providers already inside Backstage.

Getting Started

Installing the plugin

Start out by installing the plugin in your Backstage app:

# From your Backstage root directory
yarn --cwd packages/app add @backstage-community/plugin-graphiql
# in packages/app/src/App.tsx
+import { GraphiQLPage } from '@backstage-community/plugin-graphiql';

 const routes = (
   <FlatRoutes>
+    <Route path="/graphiql" element={<GraphiQLPage />} />

Adding GraphQL endpoints

For the plugin to function, you need to supply GraphQL endpoints through the GraphQLBrowse API. This is done by implementing the graphQlBrowseApiRef exported by this plugin.

If all you need is a static list of endpoints, the plugin exports a GraphQLEndpoints class that implements the GraphQLBrowseApi for you. Here's an example of how you could expose two GraphQL endpoints in your App:

# in packages/app/src/apis.ts
+import {
+  graphQlBrowseApiRef,
+  GraphQLEndpoints,
+} from '@backstage-community/plugin-graphiql';

  export const apis = [
+   createApiFactory({
+     api: graphQlBrowseApiRef,
+     deps: { errorApi: errorApiRef, githubAuthApi: githubAuthApiRef },
+     factory: ({ errorApi, githubAuthApi }) =>
+       GraphQLEndpoints.from([
+         // Use the .create function if all you need is a static URL and headers.
+         GraphQLEndpoints.create({
+           id: 'gitlab',
+           title: 'GitLab',
+           url: 'https://gitlab.com/api/graphql',
+           // Optional extra headers
+           headers: { Extra: 'Header' },
+         }),
+         {
+           id: 'hooli-search',
+           title: 'Hooli Search',
+           // Custom fetch function, this one is equivalent to using GraphQLEndpoints.create()
+           // with url set to https://internal.hooli.com/search
+           fetcher: async (params: any) => {
+             return fetch('https://internal.hooli.com/search', {
+               method: 'POST',
+               headers: { 'Content-Type': 'application/json' },
+               body: JSON.stringify(params),
+             }).then(res => res.json());
+           },
+         }
+       ]),
+   }),

Keywords

FAQs

Package last updated on 24 Aug 2024

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