-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add rover contract describe
and rover contract publish
#1475
Conversation
e4c7393
to
d67ead8
Compare
rover contract describe
and rover contract publish
After reading the docs PR (and re-learning about contracts) it looks like these includes/excludes are only related to tags, making me think we should rename --include and --no-include to --include-tags and --no-include-tags if we think we might have different filter kinds down the line. Alllsssoo, I think it would be super helpful if $ rover contract describe my-graph@my-contract-variant
Fetching description for configuration of my-graph@my-contract-variant using credentials from the default profile.
Configuration Description:
"my-graph@my-contract-variant" is derived from "my-graph@my-source-variant".
Included tags:
- "foo"
- "bar"
Excluded tags:
- "baz"
All unreachable types are hidden.
View the variant's full configuration at https://studio.apollographql.com/graph/my-graph/settings/variant?variant=my-contract-variant
💡 You can re-create this contract by running `rover contract publish my-graph@my-contract-variant --source-variant my-source-variant --include foo --include bar --exclude baz --hide-unreachable-types` I think that callout at the end would be super helpful, especially for folks with existing contracts who want to port their contracts to CI. |
I'm down to rename to
I think changing the description to be formatted like
is fine, I can file a quick backend PR for that. Agreed that giving folks a command to recreate the contract would be nice, although it'll take adding another field to the platform API. Would you be down if we shift that to follow-up work? |
…o list-style description
a952dc3
to
3a354ac
Compare
@EverlastingBugstopper
I'll file tickets for the remaining follow-up work (adding keep-old-value capabilities and showing users a command to recreate a variant) sometime tomorrow. |
Sounds good to me on getting the command construction in a follow-up. That being said, I think it might be easier to just include that code directly in Rover itself. If we keep backwards compatibility, it should be fine to just construct that on Rover's side so we can update usage down the line but old versions will continue to output the correct command suggestion. |
Two API errors I ran into during QA that were not the nicest: $ rover contract publish averys-supercloud@contract --source-variant averys-supercloud@current --hide-unreachable-types --no-include-tags --no-exclude-tag
s
Publishing configuration to averys-supercloud@contract using credentials from the default profile.
error: Exception while fetching data (/graph/upsertContractVariant) : NOT_ALLOWED_BY_USER_ROLE
$ rover contract publish averys-supercloud@contract --source-variant averys-supercloud@current --hide-unreachable-types --no-include-tags --no-exclude-tags --profile github
Publishing configuration to averys-supercloud@contract using credentials from the github profile.
error: Exception while fetching data (/graph/upsertContractVariant) : Your accounts does not include access to contracts |
…cts-commands` (#1479) Co-authored-by: Sachin D. Shinde <[email protected]>
Makes sense. When we get around to YAML configs, I imagine there will be a way to fetch a config file from the backend, and if Rover sees it can't parse it fully (e.g. sees new options/a version it doesn't know about), it could notify the user to upgrade to latest.
Yeah, we don't have a nice system/pattern for permission/capability errors unfortunately 😢 |
#[clap(flatten)] | ||
profile: ProfileOpt, | ||
|
||
/// The source variant name for this contract variant. Once set, this cannot be changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i tried specifying --source-variant
as averys-supercloud@current
instead of just current
and got an expected but unfortunately confusing error message as a result:
$ APOLLO_REGISTRY_URL="https://api-staging.apollographql.com/graphql" rover contract publish averys-supercloud-staging@contract --source-variant averys-su
percloud-staging@current --hide-unreachable-types --no-include-tags --no-exclude-tags
Publishing configuration to averys-supercloud-staging@contract using credentials from the staging profile.
error[E040]: While publishing the contract configuration and triggering launch, the following error occurred:
The source variant "averys-supercloud-staging@current" does not exist.
we could add in a check if there is an @
included, and if there is, run GraphRef::parse
. then we just use the extracted variant name if it parses correctly and the graph id matches the contract graph id you're trying to create
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, we have some existing legacy variants in production that use the @
symbol in their variant name, so we can't unambiguously tell whether a string that represents a variant name or a graph ref is one or the other 😢 .
We could have two arguments: one named --source-variant
and one named --source-variant-name
(the first taking a graph ref, and the second taking a variant name), and put them in an optional ArgGroup
. Would that be fine here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm - could we just call GraphRef::parse()
on it directly and see if it spits out a variant? there's a regex in there that could help. I think the existing --source-variant
argument is perfectly fine and we shouldn't add in --source-variant-name
in addition, I'm just anticipating that this could be a common mistake (typing the full graph ref instead of just the variant) that we could handle a bit better. Specifically, seeing the text The source variant "averys-supercloud-staging@current" does not exist.
for a variant that does exist is really confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving an update here -- we're going to change the backend API to accept both graph refs and variant names for sourceVariant
.
…if we make them optional later, we can change the code then)
…nt in Studio and link to Studio docs
# [0.11.0] - 2023-01-24 ## 🚀 Features - **Manage contract configuration - @sachindshinde, #1475 fixes #1421** Rover now includes two commands for creating, modifying, and reading contracts: `rover contract publish` and `rover contract describe`. Further documentation can be found [here](https://www.apollographql.com/docs/rover/commands/contracts). - **Easier file output with new `--output` argument - @gocamille, #1413 fixes #1212** The `--output` argument has long been used to configure the format of Rover's output. i.e. `--output json` configures Rover to print its output as a JSON object. This argument has been _renamed_ to `--format` while maintaining backwards compatibility. `--format json` should be used to configure the format of Rover's output, and the `--output` argument allows you to specify a file to print the output to. Adding `--output schema.graphql` to a `rover subgraph fetch` command will output your schema to a file. `--output data.json --format json` will output the command data to `data.json`. `--output json` will still work by itself but will now print a warning, and `--output [json|plain]` does not work with `--format [json|plain]`. Further documentation can be found [here](https://www.apollographql.com/docs/rover/conventions#output-to-a-file). - **Adds `--router-config` to `rover dev` - @EverlastingBugstopper, #1446 fixes #1373, #1345, and #1468** The new `--router-config` argument for `rover dev` allows you to pass a [router configuration file]() on startup that can configure settings such as header propagaion and CORS policies. Further documentation can be found [here](https://www.apollographql.com/docs/rover/commands/dev/#advanced-configuration). - **Auto-update router versions in `rover dev` - @EverlastingBugstopper, #1432** `rover dev` will automatically use the version of the router specified in [this plugin file](https://github.com/apollographql/rover/blob/main/latest_plugin_versions.json) instead of a hard coded version. ## 🛠 Maintenance - **Better error and help text for ELv2 license argument - @DoumanAsh, #1456 fixes #1455** The help text for the `--elv2-license` argument now includes the expected value for the argument, in addition to the error message returned when the argument is needed but not passed. - **Updates the Ariadne template URL - @patrick91, #1439** - **Updates `./examples/supergraph-demo` to `@apollo/server` v4, and removes `./examples/dev` - @EverlastingBugsttopper, #1442 fixes #1440 and #1441** - **Updates dependencies - @EverlastingBugstopper, #1481, #1450** `apollo-parser` 0.3 -> 0.4 `base64` 0.13 -> 0.21 `git2` 0.15 -> 0.16 `graphql_client` 0.11.0 -> 0.12 `serial_test` 0.9 -> 1.0 `os_info` 3.4 -> 3.5 `os_type` 2.4 -> 2.6 `termcolor` 1.1 -> 1.2 `tokio` 1.21 -> 1.24 ## 📚 Documentation - **Fixes a link to schema check example - @MayCXC, #1431**
This PR implements the first phase of #1421
That is, this PR:
rover contract describe
, which prints out a human-readable description of the configuration of a contract variant.rover contract publish
, which allows creating a contract variant (or updating its configuration) and optionally triggering a launch.Some notes:
null
to indicate "don't change this key's value". This means that most configuration is required to be specified each time the command is run.--source-variant
, which the API allows to be optional.ArgGroup
s to userequired(false)
, updating therunner.rs
/types.rs
, and removing theNone
check inrun()
.--include
or--no-include
means use the pre-existing value", we could also introduce a new argument e.g.--keep-include
that explicitly keeps the pre-existing value, and add--keep-include
to theArgGroup
instead of making theArgGroup
not required. (Similar situation for the other configuration options.) This is something to consider in the follow-up work though/doesn't need to be considered here.