Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

gulp-gql

0.1.2 • Public • Published

gulp-gql

Pre-compile graphql documents and generate a plain JS object export with separate entries for queries, mutations and fragments.

Usage

const gulp = require('gulp');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const gql = require('gulp-gql');
 
const prodEnv = (process.env.NODE_ENV === 'production');
 
gulp.task('gql', () => {
  gulp.src(['resources/graphql/**.graphql'])
    .pipe(concat('all.graphql'))
    .pipe(gql({pretty: !prodEnv}))
    .pipe(rename('gql.js'))
    .pipe(gulp.dest('src/gen'));
});

Example output:

export default {
  "query": {
    "DashboardsList": {
      "deps": [],
      "op": {
        "kind": "OperationDefinition",
        "operation": "query",
        "name": {
          "kind": "Name",
          "value": "DashboardsList"
        },
        ...
      }
    },
    ...
  },
  "mutation": {
    "CreateDashboard": {
      "deps": [],
      "op": {
        "kind": "OperationDefinition",
        "operation": "mutation",
        "name": {
          "kind": "Name",
          "value": "CreateDashboard"
        },
        ...
      }
    },
    ...
  },
  "fragment": {
    "NoteFragment": {
      "kind": "FragmentDefinition",
      "name": {
        "kind": "Name",
        "value": "NoteFragment"
      },
      ...
    },
    ...
  }
}

install

npm i gulp-gql

Downloadsweekly downloads

13

version

0.1.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability