-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove variable namespace checks from JSON selection (#6640)
- Loading branch information
1 parent
6848f8c
commit bf30386
Showing
14 changed files
with
146 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
apollo-federation/src/sources/connect/json_selection/fixtures.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::fmt::Display; | ||
use std::str::FromStr; | ||
|
||
/// A namespace used in tests to avoid dependencies on specific external namespaces | ||
#[derive(Debug, PartialEq)] | ||
pub(super) enum Namespace { | ||
Args, | ||
This, | ||
} | ||
|
||
impl FromStr for Namespace { | ||
type Err = String; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s { | ||
"$args" => Ok(Self::Args), | ||
"$this" => Ok(Self::This), | ||
_ => Err(format!("Unknown variable namespace: {}", s)), | ||
} | ||
} | ||
} | ||
|
||
impl Display for Namespace { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Self::Args => write!(f, "$args"), | ||
Self::This => write!(f, "$this"), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...pollo_federation__sources__connect__json_selection__parser__tests__error_snapshots-2.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
--- | ||
source: apollo-federation/src/sources/connect/json_selection/parser.rs | ||
expression: "JSONSelection::parse(\"$bogus\")" | ||
expression: "JSONSelection::parse(\"id $.object\")" | ||
--- | ||
Err( | ||
JSONSelectionParseError { | ||
message: "Unknown variable", | ||
fragment: "$bogus", | ||
offset: 0, | ||
message: "Named path selection must either begin with alias or ..., or end with subselection", | ||
fragment: "$.object", | ||
offset: 3, | ||
}, | ||
) |
11 changes: 0 additions & 11 deletions
11
...pollo_federation__sources__connect__json_selection__parser__tests__error_snapshots-3.snap
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.