Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
graphql-cli-prepare
Advanced tools
Plugin for graphql-cli to bundle schemas and generate bindings
Plugin for graphql-cli
to bundle schemas using graphql-import
and generate bindings using graphql-static-binding
.
The graphql-cli-prepare
plugin is shipped with graphql-cli
.
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 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 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).
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
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 |
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
extensionsTo 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
FAQs
Plugin for graphql-cli to bundle schemas and generate bindings
The npm package graphql-cli-prepare receives a total of 4,266 weekly downloads. As such, graphql-cli-prepare popularity was classified as popular.
We found that graphql-cli-prepare demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.