Skip to content

Commit

Permalink
add comment for fromContext
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Nov 6, 2024
1 parent 71209e3 commit 55161ef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apollo-router/src/spec/query/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,15 @@ impl<'a> QueryHashVisitor<'a> {
if let Some(obj) = argument.as_object() {
let context_name = Name::new("context")?;
let selection_name = Name::new("selection")?;
// the contextArgument input type is defined as follows:
// input join__ContextArgument {
// name: String!
// type: String!
// context: String!
// selection: join__FieldValue!
// }
// and that is checked by schema validation, so the `context` and `selection` fields
// are guaranteed to be present and to be strings.
if let (Some(context), Some(selection)) = (
obj.iter()
.find(|(k, _)| k == &context_name)
Expand All @@ -612,6 +621,7 @@ impl<'a> QueryHashVisitor<'a> {
if let Ok(parent_type) = Name::new(ty.as_str()) {
let mut parser = Parser::new();

// we assume that the selection was already checked by schema validation
if let Ok(field_set) = parser.parse_field_set(
Valid::assume_valid_ref(self.schema),
parent_type.clone(),
Expand Down

0 comments on commit 55161ef

Please sign in to comment.