Nourishing Pizza Microservice
Have ideas to improve npm?Join in the discussion! »

@restorecommerce/gql-botTypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published


VersionBuild StatusDependenciesCoverage Status

This is an automated GraphQL API client.

Example use cases:

  • Mass data imports.
  • Seeding of GraphQL based services.
  • Reset (deletion and re-import of data) of GraphQL based services.

Supported data formats:

  • JSON
  • YAML

The jobs are defined as JSON files whose syntax can be seen in a test job.


The module mainly consists of two usable components.

GraphQL Client

A wrapper around graphql-request. It is used to connect to a GraphQL endpoint with custom headers and to parse resource files. Such resources are described in a JSON/YAML-based DSL and they are parsed to build mutations/queries. It is possible to solely use the GraphQL Client if job automation is not required:

import { Client } from 'gql-bot';
let gqlClient = new Client({
  entry: '',
  apiKey: 'apiKey',
  headers: { /* Custom HTTP headers */}

const mutation = fs.readFileSync('test/folder/createUsers.json');
const response = await;

Job Processor

The job processor implements a pipeline mechanism to process JSON-based job files, which can contain one or more tasks, which can be run concurrently or sequentially. The job can have different options such as the maximum number of concurrent tasks and each task contains useful information for the GraphQL Client, such as the file path filter (e.g: 'create*.json'), the desired operation or useful metadata. Currently, the only implemented operation is 'sync'. There is a GraphQL-based processor, which performs calls to the GraphQL client and a generic processor, to which the GraphQL-specific processor is provided.


import { GraphQLProcessor, JobProcessor, Job } from 'gql-bot';

const jobInfo = JSON.parse(fs.readFileSync('./test/job1.json', 'utf8'));

// instantiating a job processor
jobInfo.options.processor = new GraphQLProcessor({
    entry: '',
    apiKey: 'apiKey'
const jobProcessor = new JobProcessor(jobInfo);

// starting a job
const job = new Job(); // an extension of EventEmitter which can receive job-related options
job.on('progress', (task) => {
  console.log('Progress:',, task.progress);
job.on('done', () => {
await jobProcessor.start(jobInfo, job);

Refer to tests for more details.


The following events are issued by the Job object:

  • progress (contains info specific with the task progress percentage and the task's description)
  • warn
  • error
  • done


npm i @restorecommerce/gql-bot

DownloadsWeekly Downloads






Unpacked Size

38.4 kB

Total Files


Last publish


  • avatar
  • avatar
  • avatar
  • avatar
  • avatar