Since 0.29.0

The Rover init Command

Initialize a graph locally and on GraphOS


Rover enables you to create a graph with a single interactive command.

Initializing a graph

rover init

Running rover init starts a short wizard that helps you create a new graph.

terminal
rover init

The wizard walks you through a set of questions to help you choose the best option for your use case. When you're done, you'll have:

Options

You can also pass options directly to rover init instead of answering prompts in the wizard. The wizard still asks for any information not provided via an option and will always ask for confirmation before creating any files locally.

terminal
rover init \
  --project-type <PROJECT_TYPE> \
  --organization <ORGANIZATION> \
  --project-use-case <PROJECT_USE_CASE> \
  --project-name <PROJECT_NAME> \
  --graph-id <GRAPH_ID>
Available options
OptionDescriptionPossible Values
--project-typeWhether to create a new graph or add a subgraph to an existing graph.create-new,
add-subgraph
--organizationThe ID of the GraphOS organization where the graph should be created.(your organization ID)
--project-use-caseHelps preconfigure your graph for specific patterns.connectors,
graph-ql-template
--project-nameThe name for your new graph.(your graph name)
--graph-idThe ID for your graph in GraphOS. (This must be a unique identifier.)(your graph ID)

Choosing your use case

Once you run rover init, the wizard prompts you to select your use case.

  • Start a graph with one or more REST APIs

    • Select this option to integrate REST APIs into your graph using Apollo Connectors.

  • Start a graph with recommended libraries

    • Select this option if you want to integrate data that's not accessible via a REST API. This option helps you set up a graph using the Apollo Server library.

Created credentials

After you've chosen your use case, the wizard prompts you for a project name. It generates the following credentials based on the name you enter:

  • Graph ID- A unique identifier for your graph. It represents your graph across all of Apollo.

  • Graph ref- A reference for a specific variant of your graph. It's formatted graph-id@variant. To start, GraphOS automatically creates a variant titled current for you.

  • Graph API key- Once it's generated, store it securely—you won't be able to access it later.

Next steps

Once you've completed the wizard, it provides a rover dev command with prepopulated credentials. Run this command to start developing your graph.

terminal
APOLLO_KEY=<key> \
APOLLO_GRAPH_REF=<graph-ref> \
rover dev --supergraph-config supergraph.yaml

(If you set APOLLO_KEY as an environment variable, you don't need to include it in your command.)

note
If you started with TypeScript, you also need to run the following commands in a separate terminal window before running rover dev:
terminal
1npm ci
2npm start
These commands start a subgraph server that rover dev depends on. Learn more in the getting-started.md generated when you run rover init.

Additional resources

  • After running rover init, open the generated getting-started.md file for next steps.

  • To go further, check out the Getting started guide to learn what else you can do with Apollo Connectors.

  • If you learn best with videos and exercises, this interactive course teaches you how to integrate a demo REST API into a graph using Apollo Connectors.

Feedback

Edit on GitHub

Ask Community