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

@ninjaneers/graphiql-webcomponent

v0.2.0

Published

A Webcomponent wrapper around [GraphiQL](https://github.com/graphql/graphiql) and [GraphiQL-Explorer](https://github.com/OneGraph/graphiql-explorer/).

Downloads

150

Readme

GraphiQL Webcomponent

A Webcomponent wrapper around GraphiQL and GraphiQL-Explorer.

Usage

Angular2

Add import @ninjaneers/graphiql-webcomponent; to your app.module.ts to register the Webcomponent in the browser.

Add schemas: [CUSTOM_ELEMENTS_SCHEMA] to the modules where the Webcomponent will be used.

Now you can use the Webcomponent in your Angular templates like this:

    <div *ngIf="config$ | async as config">
        <graphiql-webcomponent #graphiql
          [config]="config"
           [query]="''"
           [variables]="{}"
        ></graphiql-webcomponent>
    </div>
  export class ParentComponent implements AfterViewInit {
    
  public config$ = new BehaviorSubject({
    api: {
      url: 'http://localhost:8080/graphql',
    },
  })
  @ViewChild('graphiql')
  public graphiql: ElementRef;

  public ngAfterViewInit(): void {
    this.graphiql.nativeElement.addEventListener('QueryChange', (event) => console.dir(event));
    this.graphiql.nativeElement.addEventListener('VariablesChange', (event) => console.dir(event));  
  }
}

React

Add import @ninjaneers/graphiql-webcomponent; to your index.(js/ts) to register the webcomponent in the browser.

Now you can use the Webcomponent in your (j/t)sx like this:

const Parent = () => {
  const ref = useRef(null);
  useEffect(() => {
    ref.current.addEventListener('QueryChange', (event) => console.dir(event));
    ref.current.addEventListener('VariablesChange', (event) => console.dir(event));
  }, [ref]);
  return <graphiql-webcomponent ref={ref}
    config={config}
    query={""}
    variables={{}}
  ></graphiql-webcomponent>
}

Config

    type GraphiqlWebcomponentConfig = {
      api: {
        url: string;
        headers?: Record<string, string>;
        subscriptionUrl?: string;
        wsConnectionParams?: Record<string, string | Record<string, string>>;
      };
      defaultQuery?: string;
      disableExplorer?: boolean;
      editorTheme?: string;
      excludeMutations?: boolean;
      excludeSubscriptions?: boolean;
    };
  • api; required; contains the configuration for your connection to your GraphQL server.
    • url; required; URL of the HTTP(S) endpoint of your GraphQL server. e.g. http://localhost:3000/v1/graphql.
    • headers; headers that might be required to make a connection to your server. e.g. {"Authorization": "Bearer ..."}.
    • subscriptionUrl; required by default (see excludeSubscriptions); URL of the WS(S) endpoint of your GraphQL server. e.g. ws://localhost:3000/v1/graphql.
    • wsConnectionParams; websocket connection params. e.g. {headers: {Authorization": "Bearer ...}}.
  • defaultQuery; the default query/message that will be shown in GraphiQL.
  • disableExplorer; whether you want to use the GraphiQL-Explorer ot not. Defaults to false.
  • editorTheme; the Theme for GraphiQL. Defaults to "dracula".
  • excludeMutations; will exclude mutations from GraphiQL. Defaults to false.
  • excludeSubscriptions; will exclude mutations from GraphiQL. If false api.subscriptionUrl is required. Defaults to false.