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

chore: removes unnecessary URL parser #493

Merged
merged 1 commit into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,30 @@ All notable changes to Rover will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!-- # [x.x.x] - 2021-mm-dd
<!-- # [x.x.x] (unreleased) - 2021-mm-dd
> Important: X breaking changes below, indicated by **❗ BREAKING ❗**
## 🚀 Features
## ❗ BREAKING ❗
## 🐛 Fixes
## 🛠 Maintenance
## 📚 Documentation -->

# [x.x.x] (unreleased) - 2021-mm-dd
> Important: X breaking changes below, indicated by **❗ BREAKING ❗**
## 🚀 Features
## ❗ BREAKING ❗
## 🐛 Fixes
## 🛠 Maintenance

- **Removes unnecessary custom URL parser - [EverlastingBugstopper], [pull/493]**

`structopt` will automatically use the `FromStr` implementation on the `Url` type, so
we have removed the custom parser we were previously using.

[EverlastingBugstopper]: https://github.com/EverlastingBugstopper
[pull/493]: https://github.com/apollographql/rover/pull/493
## 📚 Documentation

# [0.0.10] - 2021-04-27

## 🚀 Features
Expand Down
3 changes: 1 addition & 2 deletions src/command/graph/introspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use url::Url;
use rover_client::{blocking::Client, query::graph::introspect};

use crate::command::RoverStdout;
use crate::utils::parsers::{parse_header, parse_url};
use crate::utils::parsers::parse_header;

#[derive(Debug, Serialize, StructOpt)]
pub struct Introspect {
/// The endpoint of the graph to introspect
#[structopt(parse(try_from_str = parse_url))]
#[serde(skip_serializing)]
pub endpoint: Url,

Expand Down
3 changes: 1 addition & 2 deletions src/command/subgraph/introspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ use url::Url;
use rover_client::{blocking::Client, query::subgraph::introspect};

use crate::command::RoverStdout;
use crate::utils::parsers::{parse_header, parse_url};
use crate::utils::parsers::parse_header;
use crate::Result;

#[derive(Debug, Serialize, StructOpt)]
pub struct Introspect {
/// The endpoint of the subgraph to introspect
#[structopt(parse(try_from_str = parse_url))]
#[serde(skip_serializing)]
pub endpoint: Url,

Expand Down
8 changes: 0 additions & 8 deletions src/utils/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use serde::Serialize;
use std::{convert::TryInto, fmt};

use crate::{error::RoverError, Result};
use url::Url;

#[derive(Debug, PartialEq)]
pub enum SchemaSource {
Expand Down Expand Up @@ -126,13 +125,6 @@ pub fn parse_query_percentage_threshold(threshold: &str) -> Result<f64> {
}
}

/// Parse Urls from the command line.
// TODO: @lrlna return error for parse url
pub fn parse_url(url: &str) -> Result<Url> {
let res = Url::parse(url)?;
Ok(res)
}

/// Parses a key:value pair from a string and returns a tuple of key:value.
/// If a full key:value can't be parsed, it will error.
pub fn parse_header(header: &str) -> Result<(String, String)> {
Expand Down