Skip to content

Instantly share code, notes, and snippets.

@abernix
Last active December 3, 2020 13:08
Show Gist options
  • Save abernix/ead2cdaad42a4232bdf7720d02e2f2b1 to your computer and use it in GitHub Desktop.
Save abernix/ead2cdaad42a4232bdf7720d02e2f2b1 to your computer and use it in GitHub Desktop.
Apollo CLI Proxy configuration

apollo CLI proxy configuration

⚠️ This is for the JavaScript apollo CLI, usually installed with npm install apollo or npx, not for any other Apollo CLI

  1. If it's not already installed (present in the project's package.json), install the apollo CLI directly into the devDependencies of the project.

    npm install --save-dev apollo
  2. Install the global-agent package into the devDependencies of the project.

    npm install --save-dev global-agent
  3. Invoke the apollo CLI, in a similar fashion to how you might invoke it in a project with npx, but with a GLOBAL_AGENT_HTTP_PROXY environment variable which is enabled by the requiring of the of the global-agent/bootstrap module from the global-agent package we installed previously.

    Important: This particular example uses apollo service:check and its options, but the same pattern should work for other commands, like apollo service:push, etc. This command is split over multiple lines using the trailing \ characters on the lines below, but it can also be issued as a single line, though the slash (\) characters should be removed. See the README for global-agent for all available environment variable options (e.g., for configuring hosts that should not be proxied, etc.).

    APOLLO_KEY=your-api-key \
      GLOBAL_AGENT_HTTP_PROXY=http://proxy-hostname:proxy-port \
      npx -n '-r global-agent/bootstrap' \
        apollo service:check \
          --serviceName <service-name> \
          --endpoint <endpointUrl> \
          --serviceURL <serviceUrl> \
          --variant <variant>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment