Launch GraphOS Studio
Since 0.17.2

The Rover persisted-queries command

Publish persisted query manifests to your persisted queries list

With GraphOS Enterprise, you can enhance a 's security by maintaining a persisted query list (PQL) for your 's . The Apollo Router checks incoming requests against the , and can be configured to reject that aren't registered in the list.

Registering to a has two steps:

  1. Generating manifests () using client-specific tooling
  2. Publishing to the using

This article details the latter. For more information on generation and other implementation steps, see the GraphOS persisted queries documentation.

Publishing a PQM

persisted-queries publish

This command requires authenticating Rover with GraphOS.

You can use to publish a for any client to any existing PQL.

Run the persisted-queries publish command, like so:

rover persisted-queries publish my-graph@my-variant \
--manifest ./persisted-query-manifest.json
  • The my-graph@my-variant is the graph ref of any the is linked to.
    • have the format graph-id@variant-name.
  • Use the --manifest option to provide the path to the manifest you want to publish.

Instead of my-graph@my-variant, you can combine the --graph-id and --list-id options to specify the you want to publish to:

rover persisted-queries publish \
--graph-id my_graph --list-id dc4b4040-30fc-4bd1-94a3-5fc1c722acc9 \
--manifest ./persisted-query-manifest.json
  • Use --graph-id to provide the 's ID
  • Use --list-id to provide the 's UUID

The persisted-queries publish command does the following:

  1. Publishes all in the provided manifest file to the linked to the specified , or to the specified PQL.

    • Publishing a manifest to a is additive. Any existing entries in the remain.
    • If you publish an with the same id but different details from an existing entry in the , the entire publish command fails with an error.
  2. Updates any other that the is applied to so that associated with those variants can fetch their updated PQL.

As with generating manifests, it's best to execute this command in your CI/CD pipeline to publish new as part of your app release process. This command requires your API key to have the Graph Admin or Persisted Query Publisher role; the latter is a role specifically designed to work with this command without exposing unnecessary information about your to users of the API key.

Relay support
Since 0.19.0

The rover persisted-queries command supports publishing persisted queries generated by the Relay compiler.

  1. Configure the Relay compiler to output a JSON manifest to a specified location according to their documentation.
  2. Use the persisted-queries publish command to publish the manifest to . The command usage is the same as when publishing Apollo-generated manifests, but you must include the --manifest-format relay :
rover persisted-queries publish my-graph@my-variant \
--manifest ./persisted-queries.json \
--manifest-format relay
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy