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

graphql-cli-prepare

v1.4.19

Published

Plugin for graphql-cli to bundle schemas and generate bindings

Downloads

21,886

Readme

graphql-cli-prepare npm

semantic-releaseCircleCIGreenkeeper badgeCode Climate
Plugin for graphql-cli to bundle schemas using graphql-import and generate bindings using graphql-static-binding.

Installation

The graphql-cli-prepare plugin is shipped with graphql-cli.

Usage

graphql prepare

Bundle schemas and generate bindings

Options:
  --dotenv         Path to .env file                                    [string]
  -p, --project    Project name                                         [string]
  --output, -o     Output folder                                        [string]
  --save, -s       Save settings to config file     [boolean] [default: "false"]
  --bundle         Process schema imports           [boolean] [default: "false"]
  --bindings       Generate bindings                [boolean] [default: "false"]
  --generator, -g  Generator used to generate bindings                  [string]
  --verbose        Show verbose output messages     [boolean] [default: "false"]
  -h, --help       Show help                                           [boolean]
  -v, --version    Show version number                                 [boolean]

Schema bundling

Schema bundling is the processing of import statements in a GraphQL schema. For more information, see graphql-import.
The first time you use schema bundling on a project, you need to provide the output folder where the processed schema will be stored:

$ graphql prepare -p app -o src/generated --bundle --save
√ Bundled schema for project app written to src/generated/app.graphql

This will also save the configuration in your .graphqlconfig file (see below).

Binding generation

Binding generation is a code generation process. A binding file will be generated for use with graphql-yoga. This binding provides type safe delegation of GraphQL queries and mutations in your resolvers. See graphcool-binding for more information.
The first time you use binding generation in your project, you need to provide an output folder for your generated binding files, and the generator you want to use:

$ graphql prepare -p database -o src/generated -g graphcool-ts --bindings --save
√ Bindings for project database written to src/generated/database.ts

This will also save the configuration in your .graphqlconfig file (see below).

Automating graphql prepare

After you have set up bundling and binding generation for all projects, you can simply run graphql prepare without any parameters to process all projects:

$ graphql prepare
√ Bundled schema for project app written to src/generated/app.graphql
√ Bindings for project database written to src/generated/database.ts

Advanced topics

Available generators

Out of the box, the following generators are provided by graphql-static-binding:

| Generator | Purpose | | ------------ | -------------------------------------------- | | prisma-ts | Typescript bindings for Prisma endpoints | | prisma-js | Javascript bindings for Prisma endpoints | | binding-ts | Typescript bindings for any GraphQL endpoint | | binding-js | Javascript bindings for any GraphQL endpoint |

Using your own generator

You can also use your own generator. To do so, you can pass a file path to the --generator parameter:

$ graphql prepare -p database --bindings -g ./myGenerator.js

More instructions for creating your own generator are coming soon in graphql-static-binding.

graphql-config extensions

To store the project configuration for bundling and bindings, graphql-cli-prepare uses two extension keys in the graphql-config configuration file. These keys can be set manually, or using the --save parameter.

# ./.graphqlconfig.yml
projects:
  app:
    schemaPath: src/schema.graphql
    extensions:
      endpoints:
        default: 'http://localhost:4000'
+       prepare-bundle: src/generated/app.graphql
  database:
    schemaPath: src/generated/prisma.graphql
    extensions:
      prisma: prisma.yml
+     prepare-binding:
+       output: src/generated/prisma.ts
+       generator: prisma-ts