Skip to content

apollosolutions/graphql-mock-cli

Repository files navigation

@apollosolutions/graphql-mock-cli

oclif

Mock a GraphQL schema in one command

The code in this repository is experimental and has been provided for reference purposes only. Community feedback is welcome but this project may not be supported in the same way that repositories in the official Apollo GraphQL GitHub organization are. If you need help you can file an issue on this repository, contact Apollo to talk to an expert, or create a ticket directly in Apollo Studio.

Usage

You can run the CLI using NPX directly on the repo.

$ npx github:@apollosolutions/graphql-mock-cli COMMAND
running command...

$ npx github:@apollosolutions/graphql-mock-cli --version
@apollosolutions/graphql-mock-cli/0.0.1 darwin-arm64 node-v22.11.0

$ npx github:@apollosolutions/graphql-mock-cli --help [COMMAND]
USAGE
  $ graphql-mock-cli COMMAND
...

To quickly mock a schema run the following

$ npx github:@apollosolutions/graphql-mock-cli mock <path to schema file>

or using Rover to pipe your supergraph schema in

Note: Regardless if you are using Federation or not, you need to use the rover graph fetch command to mock

rover graph fetch <graph ref> > temp.graphql && npx github:@apollosolutions/graphql-mock-
cli mock temp.graphql

Commands

graphql-mock-cli help [COMMAND]

Display help for graphql-mock-cli.

USAGE
  $ graphql-mock-cli help [COMMAND...] [-n]

ARGUMENTS
  COMMAND...  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for graphql-mock-cli.

See code: @oclif/plugin-help

graphql-mock-cli mock SCHEMA

Start a mock GraphQL server from a file

USAGE
  $ graphql-mock-cli mock SCHEMA [--port <value>]

ARGUMENTS
  SCHEMA  Schema file to mock

FLAGS
  --port=<value>  [default: 4000] HTTP port for server

DESCRIPTION
  Start a mock GraphQL server from a file

EXAMPLES
  $ graphql-mock-cli mock schema.graphql

  $ graphql-mock-cli mock schema.graphql --port 8080

See code: src/commands/mock/index.ts

graphql-mock-cli plugins

List installed plugins.

USAGE
  $ graphql-mock-cli plugins [--json] [--core]

FLAGS
  --core  Show core plugins.

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  List installed plugins.

EXAMPLES
  $ graphql-mock-cli plugins

See code: @oclif/plugin-plugins

graphql-mock-cli plugins add PLUGIN

Installs a plugin into graphql-mock-cli.

USAGE
  $ graphql-mock-cli plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]

ARGUMENTS
  PLUGIN...  Plugin to install.

FLAGS
  -f, --force    Force npm to fetch remote resources even if a local copy exists on disk.
  -h, --help     Show CLI help.
  -s, --silent   Silences npm output.
  -v, --verbose  Show verbose npm output.

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Installs a plugin into graphql-mock-cli.

  Uses npm to install plugins.

  Installation of a user-installed plugin will override a core plugin.

  Use the GRAPHQL_MOCK_CLI_NPM_LOG_LEVEL environment variable to set the npm loglevel.
  Use the GRAPHQL_MOCK_CLI_NPM_REGISTRY environment variable to set the npm registry.

ALIASES
  $ graphql-mock-cli plugins add

EXAMPLES
  Install a plugin from npm registry.

    $ graphql-mock-cli plugins add myplugin

  Install a plugin from a github url.

    $ graphql-mock-cli plugins add https://github.com/someuser/someplugin

  Install a plugin from a github slug.

    $ graphql-mock-cli plugins add someuser/someplugin

graphql-mock-cli plugins:inspect PLUGIN...

Displays installation properties of a plugin.

USAGE
  $ graphql-mock-cli plugins inspect PLUGIN...

ARGUMENTS
  PLUGIN...  [default: .] Plugin to inspect.

FLAGS
  -h, --help     Show CLI help.
  -v, --verbose

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Displays installation properties of a plugin.

EXAMPLES
  $ graphql-mock-cli plugins inspect myplugin

See code: @oclif/plugin-plugins

graphql-mock-cli plugins install PLUGIN

Installs a plugin into graphql-mock-cli.

USAGE
  $ graphql-mock-cli plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]

ARGUMENTS
  PLUGIN...  Plugin to install.

FLAGS
  -f, --force    Force npm to fetch remote resources even if a local copy exists on disk.
  -h, --help     Show CLI help.
  -s, --silent   Silences npm output.
  -v, --verbose  Show verbose npm output.

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Installs a plugin into graphql-mock-cli.

  Uses npm to install plugins.

  Installation of a user-installed plugin will override a core plugin.

  Use the GRAPHQL_MOCK_CLI_NPM_LOG_LEVEL environment variable to set the npm loglevel.
  Use the GRAPHQL_MOCK_CLI_NPM_REGISTRY environment variable to set the npm registry.

ALIASES
  $ graphql-mock-cli plugins add

EXAMPLES
  Install a plugin from npm registry.

    $ graphql-mock-cli plugins install myplugin

  Install a plugin from a github url.

    $ graphql-mock-cli plugins install https://github.com/someuser/someplugin

  Install a plugin from a github slug.

    $ graphql-mock-cli plugins install someuser/someplugin

See code: @oclif/plugin-plugins

graphql-mock-cli plugins link PATH

Links a plugin into the CLI for development.

USAGE
  $ graphql-mock-cli plugins link PATH [-h] [--install] [-v]

ARGUMENTS
  PATH  [default: .] path to plugin

FLAGS
  -h, --help          Show CLI help.
  -v, --verbose
      --[no-]install  Install dependencies after linking the plugin.

DESCRIPTION
  Links a plugin into the CLI for development.

  Installation of a linked plugin will override a user-installed or core plugin.

  e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
  command will override the user-installed or core plugin implementation. This is useful for development work.


EXAMPLES
  $ graphql-mock-cli plugins link myplugin

See code: @oclif/plugin-plugins

graphql-mock-cli plugins remove [PLUGIN]

Removes a plugin from the CLI.

USAGE
  $ graphql-mock-cli plugins remove [PLUGIN...] [-h] [-v]

ARGUMENTS
  PLUGIN...  plugin to uninstall

FLAGS
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Removes a plugin from the CLI.

ALIASES
  $ graphql-mock-cli plugins unlink
  $ graphql-mock-cli plugins remove

EXAMPLES
  $ graphql-mock-cli plugins remove myplugin

graphql-mock-cli plugins reset

Remove all user-installed and linked plugins.

USAGE
  $ graphql-mock-cli plugins reset [--hard] [--reinstall]

FLAGS
  --hard       Delete node_modules and package manager related files in addition to uninstalling plugins.
  --reinstall  Reinstall all plugins after uninstalling.

See code: @oclif/plugin-plugins

graphql-mock-cli plugins uninstall [PLUGIN]

Removes a plugin from the CLI.

USAGE
  $ graphql-mock-cli plugins uninstall [PLUGIN...] [-h] [-v]

ARGUMENTS
  PLUGIN...  plugin to uninstall

FLAGS
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Removes a plugin from the CLI.

ALIASES
  $ graphql-mock-cli plugins unlink
  $ graphql-mock-cli plugins remove

EXAMPLES
  $ graphql-mock-cli plugins uninstall myplugin

See code: @oclif/plugin-plugins

graphql-mock-cli plugins unlink [PLUGIN]

Removes a plugin from the CLI.

USAGE
  $ graphql-mock-cli plugins unlink [PLUGIN...] [-h] [-v]

ARGUMENTS
  PLUGIN...  plugin to uninstall

FLAGS
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Removes a plugin from the CLI.

ALIASES
  $ graphql-mock-cli plugins unlink
  $ graphql-mock-cli plugins remove

EXAMPLES
  $ graphql-mock-cli plugins unlink myplugin

graphql-mock-cli plugins update

Update installed plugins.

USAGE
  $ graphql-mock-cli plugins update [-h] [-v]

FLAGS
  -h, --help     Show CLI help.
  -v, --verbose

DESCRIPTION
  Update installed plugins.

See code: @oclif/plugin-plugins

About

Mock a schema in one command

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published