@gapi/cli-builder
TypeScript icon, indicating that this package has built-in type declarations

1.8.150 • Public • Published

@Gapi Graphql CLI Builder

Installation:

$ npm install @gapi/cli-builer
import {
  CLIBuilder,
  Environment,
  GenericEnum,
  Bootstrap,
  executeCommand,
  SpawnOptionsWithoutStdio,
} from '@gapi/cli-builder';

export const Git = (
  args: string[] = [],
  options?: SpawnOptionsWithoutStdio
) => executeCommand('git', args, options);

export enum Commands {
  GIT = 1,
}

Bootstrap(
  CLIBuilder.forRoot<typeof Commands>(
    {
      GIT: async (args: string[]) => {
        console.log('[RUN_GIT]: started arguments: ', args);
        const data = await Git(args);
        console.log('[RUN_GIT]: exited');
        return data;
      },
    },
    Commands
  )
).subscribe(() => {
  if (Environment.GRAPHQL_RUNNER_SUBSCRIPTION_URI) {
    console.log(
      'STARTED_SUBSCRIPTIONS:',
      Environment.GRAPHQL_RUNNER_SUBSCRIPTION_URI
    );
  } else {
    console.log(
      'SIGNAL_MAIN_API_STARTED',
      `Running at http://localhost:${Environment.GRAPHQL_RUNNER_API_PORT}`
    );
  }
});

Open http://localhost:42043` Execute graphql query

mutation {
  execute(cmd: GIT, args: ["status"]) {
    code
    data
    error
  }
}

Subscribing to other topic

mutation subscribeToGraphqlPubsub {
  subscribeToGraphqlPubsub(
    uri: "ws://localhost:9000/subscriptions"
    worker_type: "runner"
  ) {
    code
    data
    error
  }
}

mutation unsubscribeToGraphqlPubsub {
  unsubscribeToGraphqlPubsub {
    code
    data
    error
  }
}

Readme

Keywords

Package Sidebar

Install

npm i @gapi/cli-builder

Weekly Downloads

14

Version

1.8.150

License

MIT

Unpacked Size

228 kB

Total Files

80

Last publish

Collaborators

  • gapi