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

@hygraph/management-sdk

v1.2.4

Published

<h1 align="center">@hygraph/management-sdk</h1>

Downloads

7,205

Readme

Quickstart

import { Client } from "@hygraph/management-sdk";

const client = new Client({
  authToken: "...",
  endpoint: "..."
});

const run = async () => {
  client.createModel({
    apiId: "Post",
    apiIdPlural: "Posts",
    displayName: "Post",
  });
  const result = await client.run(true);
  if (result.errors) {
    throw new Error(result.errors)
  }
  return result;
}

run().then((result) => console.log(`Finished migration at: ${result.finishedAt}`)).catch(err => console.error("Error: ", err))

Install

npm install @hygraph/management-sdk

Usage

To use the management sdk you need to instantiate a client which allows you to interact with the Hygraph Management API.

Creating the client

To create the management sdk client you need to pass the following parameters:

  • Authentication Token authToken.

    Can be retrieved from Settings > API Access > Permanent Auth Tokens on https://app.hygraph.com. Make sure the token has proper management permissions depending on what you plan to execute via the sdk.

  • Hygraph Content Api Endpoint endpoint.

    Endpoint of the Content API that belongs to the environment that you plan to interact with. The URL can be retrieved from Settings > Environments > Endpoints on https://app.hygraph.com

  • Migration Name name [optional].

    Every migration has a unique name. If unspecified, a name would be generated and will be part of the response of a successful migration.

    Subsequent migrations with same name will fail.

const { Client } = require("@hygraph/management-sdk");

const client = new Client({
  authToken,
  endpoint,
  name, // optional
});

Running a Migration

The run method runs the migration.

By default, migrations run in the foreground, meaning that the SDK client will return the results of all actions that were executed in the Management API. Passing an optional boolean argument as false configures the migration to run in the background. A successful result here does only mean that the actions were successfully scheduled, but not executed.

const result = await client.run(foreground);

if (result.errors) {
  console.log(result.errors);
} else {
  console.log(result.name);
}

Dry Run a Migration

A migration can be dry run to preview what changes would be applied.

const changes = client.dryRun();

console.log(changes);

Supported operations

All operations that can be executed by the SDK can be found in the TypeScript Type Definitions (Client.d.ts).