How to use graphql-playground-html - 10 common examples

To help you get started, we’ve selected a few graphql-playground-html examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prisma-labs / graphql-playground / packages / graphql-playground-react / scripts / start.js View on Github external
prepareProxy,
  prepareUrls,
} = require('react-dev-utils/WebpackDevServerUtils');
const openBrowser = require('react-dev-utils/openBrowser');
const paths = require('../config/paths');
const config = require('../config/webpack.config.dev');
const createDevServerConfig = require('../config/webpackDevServer.config');

const useYarn = fs.existsSync(paths.yarnLockFile);
const isInteractive = process.stdout.isTTY;

const { renderPlaygroundPage } = require('graphql-playground-html');

// Create the playground entry point if it doesn't exist
if(!fs.existsSync(paths.appHtml)) {
  fs.writeFileSync(paths.appHtml, renderPlaygroundPage({env: 'react'}));
}

// Warn and crash if required files are missing
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
  process.exit(1);
}

// Tools like Cloud9 rely on this.
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
const HOST = process.env.HOST || '0.0.0.0';

// We attempt to use the default port but if it is busy, we offer the user to
// run on a different port. `detect()` Promise resolves to the next free port.
choosePort(HOST, DEFAULT_PORT)
  .then(port => {
  if (port == null) {
github prisma-labs / graphql-playground / packages / graphql-playground-react / scripts / build.js View on Github external
var filesize = require('filesize');
var gzipSize = require('gzip-size').sync;
var webpack = require('webpack');
var config = require('../config/webpack.config.prod');
var paths = require('../config/paths');
var checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
var recursive = require('recursive-readdir');
var stripAnsi = require('strip-ansi');

var useYarn = fs.existsSync(paths.yarnLockFile);

const { renderPlaygroundPage } = require('graphql-playground-html');

// Create the playground entry point if it doesn't exist
if(!fs.existsSync(paths.appHtml)) {
  fs.writeFileSync(paths.appHtml, renderPlaygroundPage({env: 'react'}));
}

// Warn and crash if required files are missing
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
  process.exit(1);
}

// Input: /User/dan/app/build/static/js/main.82be8.js
// Output: /static/js/main.ts
function removeFileNameHash(fileName) {
  return fileName
    .replace(paths.appBuild, '')
    .replace(/\/?(.*)(\.\w+)(\.js|\.css)/, (match, p1, p2, p3) => p1 + p3);
}

// Input: 1024, 2048
github prisma-labs / graphql-playground / packages / graphql-playground-electron / webpack.config.build.js View on Github external
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const cssnano = require('cssnano')
const path = require('path')
const config = require('./webpack.config')
const HappyPack = require('happypack')
const os = require('os')
const fs = require('fs')
const UglifyJSParallelPlugin = require('webpack-uglify-parallel')
const { renderPlaygroundPage } = require('graphql-playground-html')

const appEntrypoint = 'src/renderer/index.html'

// Create the playground entry point if it doesn't exist
if (!fs.existsSync(appEntrypoint)) {
  fs.writeFileSync(appEntrypoint, renderPlaygroundPage({ env: 'react' }))
}

module.exports = {
  devtool: 'source-map',
  target: 'electron-renderer',
  entry: {
    app: ['./src/renderer'],
  },
  output: {
    path: __dirname + '/dist',
    filename: '[name].[hash].js',
    sourceMapFilename: '[file].map',
    publicPath: './',
  },
  node: {
    __dirname: false,
github prisma-labs / graphql-playground / packages / graphql-playground-electron / webpack.config.js View on Github external
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
  .BundleAnalyzerPlugin
const path = require('path')
const fs = require('fs')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const HappyPack = require('happypack')
const { renderPlaygroundPage } = require('graphql-playground-html')

const appEntrypoint = 'src/renderer/index.html'

// Create the playground entry point if it doesn't exist
if (!fs.existsSync(appEntrypoint)) {
  fs.writeFileSync(appEntrypoint, renderPlaygroundPage({ env: 'react' }))
}

module.exports = {
  devtool: 'cheap-module-eval-source-map',
  entry: './src/renderer',
  target: 'electron',
  output: {
    filename: '[name].[hash].js',
    publicPath: '/',
  },
  module: {
    rules: [
      {
        enforce: 'pre',
        test: /\.ts(x?)$/,
        loader: 'tslint-loader',
github Lucifier129 / graphql-dynamic / express.js View on Github external
router.get('/', (req, res) => {
      let playground = renderPlaygroundPage({
        ...playgroundOptions,
        ...req.graphqlPlaygroundOptions
      })
      res.setHeader('Content-Type', 'text/html')
      res.end(playground)
    })
  }
github prisma-labs / graphql-playground / packages / graphql-playground-middleware-lambda / src / index.ts View on Github external
return async (
    event,
    lambdaContext: lambda.Context,
    callback: lambda.Callback,
  ) => {
    const body = await renderPlaygroundPage(options)
    callback(null, {
      statusCode: 200,
      headers: {
        'Content-Type': 'text/html',
      },
      body,
    })
  }
}
github prisma-labs / graphql-playground / packages / graphql-playground-middleware-express / src / index.ts View on Github external
return (req, res, next) => {
    res.setHeader('Content-Type', 'text/html')
    const playground = renderPlaygroundPage(options)
    res.write(playground)
    res.end()
  }
}
github prisma-labs / graphql-playground / packages / graphql-playground-middleware-koa / src / index.ts View on Github external
return async function voyager(ctx, next) {
    try {
      ctx.body = await renderPlaygroundPage(options)
      await next()
    } catch (err) {
      ctx.body = { message: err.message }
      ctx.status = err.status || 500
    }
  }
}
github prisma-labs / graphql-playground / packages / graphql-playground-middleware-hapi / src / index.ts View on Github external
handler: (request, h) =>
        h.response(renderPlaygroundPage(middlewareOptions)).type('text/html'),
    })
github codejie / fastify-apollo-step / lib / apollo-graphiql.js View on Github external
handler: function (request, reply) {
            reply.header('Content-Type', 'text/html')
                .send(GraphqlPlaygroundHtml.renderPlaygroundPage({
                    endpoint: options.endpoint,//iql
                    subscriptionsEndpoint: options.subscriptionsEndpoint,//'/subscriptions',
                    version: '1.7.1'
                }));
        }
    }

graphql-playground-html

GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular graphql-playground-html functions