npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@graphql-ez/plugin-altair

v0.11.3

Published

Integration with [Altair GraphQL Client IDE](https://altair.sirmuel.design/)

Downloads

1,825

Readme

@graphql-ez/plugin-altair

Integration with Altair GraphQL Client IDE

Usage

import { ezAltairIDE } from '@graphql-ez/plugin-altair';

const ezApp = CreateApp({
  ez: {
    plugins: [
      ezAltairIDE({
        // Options
      }),
      // ...
    ],
  },
  // ...
});

Options

Most of these types come from altair-static

type AltairOptions =
  | {
      /**
       * @default "/altair"
       */
      path?: string;

      /**
       * URL to be used as a base for relative URLs
       */
      baseURL?: string;
      /**
       * Whether to render the initial options in a separate javascript file or not.
       * Use this to be able to enforce strict CSP rules.
       * @default false
       */
      serveInitialOptionsInSeperateRequest?: boolean;

      /**
       * URL to set as the server endpoint
       */
      endpoint?: string;
      /**
       * URL to set as the subscription endpoint
       */
      subscriptionsEndpoint?: string;
      /**
       * Initial query to be added
       */
      initialQuery?: string;
      /**
       * Initial variables to be added
       */
      initialVariables?: string;
      /**
       * Initial pre-request script to be added
       */
      initialPreRequestScript?: string;
      /**
       * Initial post-request script to be added
       */
      initialPostRequestScript?: string;
      /**
       * Initial headers object to be added
       * @example
       * {
       *  'X-GraphQL-Token': 'asd7-237s-2bdk-nsdk4'
       * }
       */
      initialHeaders?: IDictionary;
      /**
       * Initial Environments to be added
       * @example
       * {
       *   base: {
       *     title: 'Environment',
       *     variables: {}
       *   },
       *   subEnvironments: [
       *     {
       *       title: 'sub-1',
       *       variables: {}
       *     }
       *   ]
       * }
       */
      initialEnvironments?: IInitialEnvironments;
      /**
       * Namespace for storing the data for the altair instance.
       * Use this when you have multiple altair instances running on the same domain.
       * @example
       * instanceStorageNamespace: 'altair_dev_'
       */
      instanceStorageNamespace?: string;
      /**
       * Initial app settings to use
       */
      initialSettings?: Partial<SettingsState>;
      /**
       * Initial subscriptions provider
       *
       * @default "websocket"
       */
      initialSubscriptionsProvider?: SubscriptionProviderIds;
      /**
       * Initial subscriptions connection params
       */
      initialSubscriptionsPayload?: IDictionary;
      /**
       * Indicates if the state should be preserved for subsequent app loads
       *
       * @default true
       */
      preserveState?: boolean;
      /**
       * HTTP method to use for making requests
       */
      initialHttpMethod?: HttpVerb;
    }
  | boolean;

Unpkg Version

This plugin also provides a version of Altair that is hosted by Unpkg, which is very useful when you are bundling your API, since the static files of Altair might not be included in your final bundle, but it will require an internet connection from your API.

import { ezUnpkgAltairIDE } from '@graphql-ez/plugin-altair';

const ezApp = CreateApp({
  ez: {
    plugins: [
      ezUnpkgAltairIDE({
        // Options
      }),
      // ...
    ],
  },
  // ...
});

Next.js Usage

In Next.js you need to use this plugin's handler explicitly in your API routes, for example, following the file structure: /pages/api/altair/[[...any]].ts, and using this snippet:

// /pages/api/altair/[[...any]].ts
import { UnpkgAltairHandler } from '@graphql-ez/plugin-altair/unpkg';

export default UnpkgAltairHandler({
  path: '/api/altair',
  endpointURL: '/api/graphql',
});

Vercel Usage

For Vercel you need to use this plugin's handler explicitly in your API routes in conjunction with a custom vercel.json, for example, following the file structure: /api/altair.ts, and using these snippets:

// /api/altair.ts
import { UnpkgAltairHandler } from '@graphql-ez/plugin-altair/unpkg';

export default UnpkgAltairHandler({
  path: '/api/altair',
  endpointURL: '/api/graphql',
});

/vercel.json

{
  "rewrites": [
    {
      "source": "/api/altair/(.*)",
      "destination": "/api/altair"
    }
  ]
}

Cloudflare Workers Usage

For Cloudflare Workers you can only use the Unpkg version, and make sure to import it via '@graphql-ez/plugin-altair/unpkg':

import { ezUnpkgAltairIDE } from '@graphql-ez/plugin-altair/unpkg';

const ezApp = CreateApp({
  ez: {
    plugins: [
      ezUnpkgAltairIDE({
        // Options
      }),
      // ...
    ],
  },
  // ...
});

Sveltekit Usage

Altair requires a "wildcard" route, therefore, you have to define the endpoint as Fallthrough Routes, for example /src/routes/api/[...any].ts

For example:

// /src/routes/api/[...any].ts

// import { ezAltairIDE } from '@graphql-ez/plugin-altair';
import { ezUnpkgAltairIDE } from '@graphql-ez/plugin-altair/unpkg';

const ezApp = CreateApp({
  path: '/api/graphql',
  ez: {
    plugins: [
      // ...
      ezUnpkgAltairIDE({
        path: '/api/altair',
      }),
    ],
  },
  // ...
});

const { handler } = ezApp.buildApp();

export const get = handler;

export const post = handler;