Skip to content
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
13 changes: 13 additions & 0 deletions .changesets/fix_renee_operation_variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Fix GraphQL query directives validation bug ([PR #5753](https://github.com/apollographql/router/pull/5753))

GraphQL supports an obscure syntax, where a variable is used in a directive application on the same operation where the variable is declared.

The router used to reject queries like this, but now they are accepted:

```graphql
query GetSomething($var: Int!) @someDirective(argument: $var) {
something
}
```

By [@goto-bus-stop](https://github.com/goto-bus-stop) in https://github.com/apollographql/router/pull/5753
39 changes: 8 additions & 31 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"

[[package]]
name = "apollo-compiler"
version = "1.0.0-beta.19"
version = "1.0.0-beta.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b21b81064ebf506f5a4073f5ef7a3a9cfdba29904814fa3f42612b9055b37f2"
checksum = "07961541ebb5c85cc02ea0f08357e31b30537674bbca818884f1fc658fa99116"
dependencies = [
"ahash",
"apollo-parser",
Expand All @@ -412,16 +412,6 @@ dependencies = [
"uuid",
]

[[package]]
name = "apollo-encoder"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee9f27b20841d14923dd5f0714a79f86360b23492d2f98ab5d1651471a56b7a4"
dependencies = [
"apollo-parser",
"thiserror",
]

[[package]]
name = "apollo-federation"
version = "1.52.0"
Expand Down Expand Up @@ -464,9 +454,9 @@ dependencies = [

[[package]]
name = "apollo-parser"
version = "0.7.7"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bb7c8a9776825e5524b5ab3a7f478bf091a054180f244dff85814452cb87d90"
checksum = "f17a43dc64e71ca7140e646b99bf86ae721ebb801d2aec44e29a654c4d035ab8"
dependencies = [
"memchr",
"rowan",
Expand Down Expand Up @@ -647,7 +637,7 @@ version = "1.52.0"
dependencies = [
"apollo-parser",
"apollo-router",
"apollo-smith 0.5.0",
"apollo-smith",
"arbitrary",
"criterion",
"memory-stats",
Expand Down Expand Up @@ -691,22 +681,9 @@ dependencies = [

[[package]]
name = "apollo-smith"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "441a51f1055d2eebcda41b55066de925502e11c97097c6d1bab0da5bdeb5c70f"
dependencies = [
"apollo-encoder",
"apollo-parser",
"arbitrary",
"once_cell",
"thiserror",
]

[[package]]
name = "apollo-smith"
version = "0.9.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ae8c0ec27715028b24a0a98ac53e88ac4a980e6d519cdb37265d2f2c76c864a"
checksum = "84ef0a8fba05f32a14d03eb3ff74f556cecca820012d5846770b839c75332b38"
dependencies = [
"apollo-compiler",
"apollo-parser",
Expand Down Expand Up @@ -6144,7 +6121,7 @@ dependencies = [
"apollo-compiler",
"apollo-parser",
"apollo-router",
"apollo-smith 0.9.0",
"apollo-smith",
"async-trait",
"env_logger 0.10.2",
"http 0.2.12",
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ debug = 1
# Dependencies used in more than one place are specified here in order to keep versions in sync:
# https://doc.rust-lang.org/cargo/reference/workspaces.html#the-dependencies-table
[workspace.dependencies]
apollo-compiler = "=1.0.0-beta.19"
apollo-parser = "0.7.6"
apollo-smith = { version = "0.5.0", features = ["parser-impl"] }
apollo-compiler = "=1.0.0-beta.20"
apollo-parser = "0.8.0"
apollo-smith = "0.10.0"
async-trait = "0.1.77"
hex = { version = "0.4.3", features = ["serde"] }
http = "0.2.11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn test_if_directives_with_arguments_applied_on_queries_are_ok() {
}

#[test]
#[should_panic(expected = r#"unused variable: `$some_var`"#)]
#[should_panic(expected = r#"snapshot assertion"#)]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected error changed because apollo-compiler fixed validation. This test still fails for other reasons, which will be addressed in #5743.

// TODO: investigate this failure
fn subgraph_query_retains_the_query_variables_used_in_the_directives_applied_to_the_query() {
let planner = planner!(
Expand Down
2 changes: 1 addition & 1 deletion examples/supergraph-sdl/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
anyhow = "1"
apollo-compiler = "=1.0.0-beta.19"
apollo-compiler = "=1.0.0-beta.20"
apollo-router = { path = "../../../apollo-router" }
async-trait = "0.1"
tower = { version = "0.4", features = ["full"] }
Expand Down
4 changes: 2 additions & 2 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"
apollo-compiler.workspace = true
apollo-parser = "0.7.6"
apollo-smith = "0.9.0"
apollo-parser.workspace = true
apollo-smith.workspace = true
env_logger = "0.10.2"
log = "0.4"
reqwest = { workspace = true, features = ["json", "blocking"] }
Expand Down