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

@autoinvent/conveyor

v1.0.0-beta.4

Published

GraphiQL for magql

Downloads

204

Readme

Conveyor

Conveyor is a comprehensive UI library for introspecting and interacting with GraphQL APIs generated by the Magql library. It provides an intuitive and user-friendly interface for performing CRUD (Create, Read, Update, Delete) operations on your GraphQL data.

Features

  • Automatic UI Generation: Conveyor automatically introspects your GraphQL schema and generates a UI that corresponds to your data structure. This includes forms for data entry, tables for data viewing, and even more complex UI structures for nested or related data.

Prerequisites

Before using Conveyor, you need to have a GraphQL API generated by the Magql library. Magql provides a robust, flexible, and easy-to-use way to create a GraphQL API from your existing data.

Usage

First, install the library:

pnpm install @autoinvent/conveyor

Then you can use it in your project:

  • Check out outline for component description and usages.
  • Check out request examples for examples on how to use different request APIs.

Usage from CDN

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <link rel="icon" type="image/png" href="https://raw.githubusercontent.com/autoinvent/conveyor/main/src/logo.svg" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Conveyor</title>
  <style>
    body {
      height: 100%;
      margin: 0;
      width: 100%;
      overflow: hidden;
    }
  </style>

  <!--
      This example depends on Promise and fetch, which are available in modern browsers, but can be "polyfilled" for older browsers.
      Conveyor itself depends on React DOM.
      If you do not want to rely on a CDN, you can host these files locally or nclude them directly in your favored resource bundler.
    -->
  <script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
  <link crossorigin href="https://unpkg.com/@autoinvent/[email protected]/dist/styles/index.css" rel="stylesheet" />
  <script crossorigin src="https://unpkg.com/@autoinvent/[email protected]/dist/conveyor.umd.js"></script>
</head>

<body>
  <div id="conveyorAdmin">Loading...</div>
  <script defer>
    const ConveyorAdmin = window.conveyor.ConveyorAdmin;

    const gqlUrl = "/graphql";
    const responseHandler = async (response) => {
      const parsedResponse = await response.json();
      if (parsedResponse?.data) {
        return parsedResponse.data;
      } else if (parsedResponse?.errors) {
        throw parsedResponse.errors;
      } else {
        throw parsedResponse;
      }
    };
    const useGQLQueryResponse = (graphQLParams) => {
      return fetch(gqlUrl, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          query: graphQLParams.document,
          variables: graphQLParams.variables,
        }),
      }).then(responseHandler);
    };
    const useGQLMutationRequest = (graphQLParams) => {
      return (options) =>
        fetch(gqlUrl, {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            query: graphQLParams.document,
            variables: options?.variables,
          }),
        }).then(responseHandler);
    };

    ReactDOM.render(
      React.createElement(ConveyorAdmin, {
        useGQLQueryResponse: useGQLQueryResponse,
        useGQLMutationRequest: useGQLMutationRequest,
      }),
      document.getElementById("conveyorAdmin")
    );
  </script>
</body>

</html>

Scripts

  • pnpm dev - start a development server for testing the conveyor library with hot reload.
  • pnpm build - build library for production. The generated files will be on the dist folder. pnpm pack will package these files into a tarball for install.
  • pnpm preview - locally preview the production build.
  • pnpm test - run tests in watch mode.
  • pnpm test:ci - run tests once without watch mode.
  • pnpm test:ui - run tests with ui.
  • pnpm format - format all files with Rome.
  • pnpm lint - runs TypeScript, Rome and Stylelint.
  • pnpm validate - runs lint, test:ci.

Resources