Skip to content
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

fix: updates types to match new schema #697

Merged
merged 3 commits into from
Aug 3, 2021
Merged

Conversation

EverlastingBugstopper
Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper commented Jul 29, 2021

Fixes #696

Situation

When we first set up builds for rover-client, we were manually downloading the schema and committing it periodically to the repo. Unfortunately, this was creating 7k line diffs on most PRs just from the schema changes, and it wasn't automated. This was a pain! From there, we added the schema to our .gitignore and started downloading the schema automatically if the builder was connected to the internet. We then set up an escape hatch for if we ever wanted to substitute a different schema at compile time. (APOLLO_GRAPHQL_SCHEMA_URL).

Due to recent breaking changes in Apollo's GraphQL schema (which shouldn't actually cause issues with Rover aside from codegen), we want to start using APOLLO_GRAPHQL_SCHEMA_URL to build Rover with a schema that plays nicely with the types from old versions.

Problem

Unfortunately, we never tested that using std::env::var would work properly in build.rs files, and... it turns out they don't. There is a significant difference between the option_env! macro, which checks for environment variables at compile time, and std::env::var (which is what we were using up until this PR). That means that APOLLO_GRAPHQL_SCHEMA_URL is never

Resolution

This PR does a few things:

  • On every release, upload a copy of the GraphQL API Schema from the point in time when that version of Rover was built.
  • Create a new --version parameter for cargo xtask dist that will go fetch that schema from the GitHub releases API if the automatically downloaded schema fails to build. It does this by cloning the repo into a temp directory, attempting to build once, and when it inevitably fails, it downloads the schema from the version's GitHub release assets and replaces the one it downloaded automatically from Apollo.
  • For newer versions of Rover, the APOLLO_GRAPHQL_SCHEMA_URL environment variable is actually supported, so cargo xtask install --version where version >= v0.2.0.beta.1 will go straight to GitHub releases to download the schema and we won't have to build twice.

Additionally this PR updates the version of rover on main to handle the new non-nullable field that broke our codegen.

@EverlastingBugstopper EverlastingBugstopper added the fix 🩹 fixes a bug label Jul 29, 2021
@EverlastingBugstopper EverlastingBugstopper linked an issue Jul 29, 2021 that may be closed by this pull request
@EverlastingBugstopper EverlastingBugstopper merged commit 126813e into main Aug 3, 2021
@EverlastingBugstopper EverlastingBugstopper deleted the avery/quick-fix branch August 3, 2021 00:53
This was referenced Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix 🩹 fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rover 0.1.9 build failure
1 participant