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

docs: add signature generation configuration #5442

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
09e7412
Add raw info about operation signature configuration
Meschreiber Jun 12, 2024
6e791d6
Copyedit
Meschreiber Jun 13, 2024
a1dd372
use the JSON path implementation from serde-json-bytes (#5346)
Geal Jun 13, 2024
e3412dc
Rename the scaffold `Cargo.toml` files so that they don't confuse car…
dylan-apollo Jun 13, 2024
5de98ef
fixed a (type-position, schema) inconsistency in `compute_nodes_for_k…
duckki Jun 13, 2024
4fff2b4
Add example before/after signatures
Meschreiber Jun 13, 2024
6a7a384
Merge branch 'dev' into docs/add-signature-generation-configuration
Meschreiber Jun 13, 2024
e15d0d9
add selector for router service in custom telemetry (#5392)
bnjjj Jun 14, 2024
028b287
Add cost information to protobuf traces (#5430)
BrynCooke Jun 14, 2024
497c041
Remove Enterprise tag
Meschreiber Jun 14, 2024
7885a34
Merge branch 'dev' into docs/add-signature-generation-configuration
Meschreiber Jun 14, 2024
6be2b07
Fix bug in selection set equality checking (#5457)
sachindshinde Jun 14, 2024
bbe1f35
Fix bug in interface object type collection during query planner cons…
sachindshinde Jun 14, 2024
b4326a3
fix: fixed filter_on_schema (#5459)
duckki Jun 15, 2024
8f848ee
test: updated `plan_simple_root_field_query_for_multiple_subgraphs` t…
duckki Jun 15, 2024
1b3434c
Updated/added the comments on tests (#5445)
duckki Jun 15, 2024
3fc39ab
fixed `inputs_for_require` to use the entity_type/schema (#5460)
duckki Jun 15, 2024
0f388fc
fix(bridge_query_planner): change log level for mismatches (#5450)
lrlna Jun 17, 2024
e90de4b
Merge branch 'dev' into docs/add-signature-generation-configuration
Meschreiber Jun 17, 2024
4b2233e
prep release: v1.49.0-alpha.0
abernix Jun 12, 2024
dfe1bf2
prep release: v1.49.0-rc.0
bnjjj Jun 13, 2024
c132de4
prep release: v1.49.0-rc.1
lrlna Jun 17, 2024
085d924
fix(fed): bring in commit
duckki Jun 13, 2024
c4036af
fixed a (type-position, schema) inconsistency in `compute_nodes_for_k…
duckki Jun 13, 2024
4cb1fdb
Fix bug in interface object type collection during query planner cons…
sachindshinde Jun 14, 2024
6d2b65d
fixed `inputs_for_require` to use the entity_type/schema (#5460)
duckki Jun 15, 2024
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
10 changes: 6 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5528,9 +5528,9 @@ dependencies = [

[[package]]
name = "regex"
version = "1.10.3"
version = "1.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
dependencies = [
"aho-corasick",
"memchr",
Expand Down Expand Up @@ -6228,12 +6228,14 @@ dependencies = [

[[package]]
name = "serde_json_bytes"
version = "0.2.2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "feb260b2939374fad6f939f803662d4971d03395fcd03752b674bdba06565779"
checksum = "9eb67259abd83636e3b2f4700ddc3ecfdbfe7b1b89e824da42bfea6530caf03b"
dependencies = [
"bytes",
"indexmap 2.2.3",
"jsonpath-rust",
"regex",
"serde",
"serde_json",
]
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ serde_json = { version = "1.0.114", features = [
"preserve_order",
"float_roundtrip",
] }
serde_json_bytes = { version = "0.2.2", features = ["preserve_order"] }
serde_json_bytes = { version = "0.2.3", features = ["preserve_order"] }
sha1 = "0.10.6"
tempfile = "3.10.0"
tokio = { version = "1.36.0", features = ["full"] }
Expand Down
6 changes: 5 additions & 1 deletion apollo-federation/src/query_plan/fetch_dependency_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3062,6 +3062,10 @@ fn compute_nodes_for_key_resolution<'a>(
let dest = stack_item.tree.graph.node_weight(dest_id)?;
// We shouldn't have a key on a non-composite type
let source_type: CompositeTypeDefinitionPosition = source.type_.clone().try_into()?;
let source_schema: ValidFederationSchema = dependency_graph
.federated_query_graph
.schema_by_source(&source.source)?
.clone();
let dest_type: CompositeTypeDefinitionPosition = dest.type_.clone().try_into()?;
let dest_schema: ValidFederationSchema = dependency_graph
.federated_query_graph
Expand Down Expand Up @@ -3153,7 +3157,7 @@ fn compute_nodes_for_key_resolution<'a>(
let node =
FetchDependencyGraph::node_weight_mut(&mut dependency_graph.graph, stack_item.node_id)?;
let typename_field = Arc::new(OpPathElement::Field(Field::new_introspection_typename(
&dependency_graph.supergraph_schema,
&source_schema,
&source_type,
None,
)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ fn can_use_a_key_on_an_interface_object_type() {
}

#[test]
#[should_panic(
expected = r#"Cannot add selection of field "I.__typename" to selection set of parent type "I" that is potentially an interface object type at runtime"#
)]
// TODO: investigate this failure
fn can_use_a_key_on_an_interface_object_from_an_interface_object_type() {
let planner = planner!(
S1: SUBGRAPH1,
Expand Down Expand Up @@ -181,6 +177,8 @@ fn only_uses_an_interface_object_if_it_can() {
#[should_panic(
expected = "Cannot add selection of field \"I.__typename\" to selection set of parent type \"I\" that is potentially an interface object type at runtime"
)]
// TODO: investigate this failure
// - Fails to rebase on an interface object type in a subgraph.
fn does_not_rely_on_an_interface_object_directly_for_typename() {
let planner = planner!(
S1: SUBGRAPH1,
Expand Down Expand Up @@ -232,9 +230,10 @@ fn does_not_rely_on_an_interface_object_directly_for_typename() {

#[test]
#[should_panic(
expected = r#"Cannot add selection of field "I.__typename" to selection set of parent type "I" that is potentially an interface object type at runtime"#
expected = r#"Cannot add selection of field "I.id" to selection set of parent type "A""#
)]
// TODO: investigate this failure
// - Fails to rebase on an interface object type in a subgraph.
fn does_not_rely_on_an_interface_object_directly_if_a_specific_implementation_is_requested() {
let planner = planner!(
S1: SUBGRAPH1,
Expand Down Expand Up @@ -377,10 +376,6 @@ fn can_use_a_key_on_an_interface_object_type_even_for_a_concrete_implementation(
}

#[test]
#[should_panic(
expected = r#"Cannot add selection of field "I.__typename" to selection set of parent type "I" that is potentially an interface object type at runtime"#
)]
// TODO: investigate this failure
fn handles_query_of_an_interface_field_for_a_specific_implementation_when_query_starts_with_interface_object(
) {
let planner = planner!(
Expand Down Expand Up @@ -437,9 +432,10 @@ fn handles_query_of_an_interface_field_for_a_specific_implementation_when_query_

#[test]
#[should_panic(
expected = r#"Cannot add selection of field "I.__typename" to selection set of parent type "I" that is potentially an interface object type at runtime"#
expected = r#"Cannot add selection of field "I.id" to selection set of parent type "A""#
)]
// TODO: investigate this failure
// - Fails to rebase on an interface object type in a subgraph.
fn it_avoids_buffering_interface_object_results_that_may_have_to_be_filtered_with_lists() {
let planner = planner!(
S1: r#"
Expand Down
6 changes: 6 additions & 0 deletions apollo-router-scaffold/templates/base/.scaffold.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Created new Apollo Router project '{{name}}'.
> Read [our licensing page](https://www.apollographql.com/docs/resources/elastic-license-v2-faq/) for more details.
"""

[hooks]
post = [
"mv Cargo.template.toml Cargo.toml",
"mv xtask/Cargo.template.toml xtask/Cargo.toml",
]

[parameters]
[parameters.name]
type = "string"
Expand Down
9 changes: 5 additions & 4 deletions apollo-router/src/plugin/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::str::FromStr;
use access_json::JSONQuery;
use http::header::HeaderName;
use http::HeaderValue;
use jsonpath_rust::JsonPathInst;
use regex::Regex;
use serde::de;
use serde::de::Error;
Expand Down Expand Up @@ -211,7 +210,9 @@ where
deserializer.deserialize_str(RegexVisitor)
}

pub(crate) fn deserialize_jsonpath<'de, D>(deserializer: D) -> Result<JsonPathInst, D::Error>
pub(crate) fn deserialize_jsonpath<'de, D>(
deserializer: D,
) -> Result<serde_json_bytes::path::JsonPathInst, D::Error>
where
D: serde::Deserializer<'de>,
{
Expand All @@ -221,7 +222,7 @@ where
struct JSONPathVisitor;

impl<'de> serde::de::Visitor<'de> for JSONPathVisitor {
type Value = JsonPathInst;
type Value = serde_json_bytes::path::JsonPathInst;

fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
write!(formatter, "a JSON path")
Expand All @@ -231,6 +232,6 @@ impl<'de> serde::de::Visitor<'de> for JSONPathVisitor {
where
E: serde::de::Error,
{
JsonPathInst::from_str(s).map_err(serde::de::Error::custom)
serde_json_bytes::path::JsonPathInst::from_str(s).map_err(serde::de::Error::custom)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,6 @@ mod tests {
use apollo_compiler::ast::Name;
use apollo_compiler::ast::NamedType;
use apollo_compiler::executable::SelectionSet;
use apollo_compiler::execution::JsonMap;
use http::HeaderMap;
use http::HeaderName;
use http::Method;
Expand All @@ -1912,6 +1911,7 @@ mod tests {
use schemars::gen::SchemaGenerator;
use serde::Deserialize;
use serde_json::json;
use serde_json_bytes::ByteString;
use serde_json_bytes::Value;

use super::*;
Expand All @@ -1931,6 +1931,8 @@ mod tests {
use crate::services::RouterResponse;
use crate::Context;

type JsonMap = serde_json_bytes::Map<ByteString, Value>;

#[derive(RustEmbed)]
#[folder = "src/plugins/telemetry/config_new/fixtures"]
struct Asset;
Expand Down
55 changes: 9 additions & 46 deletions apollo-router/src/plugins/telemetry/config_new/selectors.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use access_json::JSONQuery;
use derivative::Derivative;
use jsonpath_rust::JsonPathFinder;
use jsonpath_rust::JsonPathInst;
use opentelemetry_api::Value;
use schemars::JsonSchema;
use serde::Deserialize;
use serde_json_bytes::path::JsonPathInst;
use serde_json_bytes::ByteString;
use sha2::Digest;

Expand Down Expand Up @@ -818,17 +817,7 @@ impl Selector for SupergraphSelector {
default,
..
} => if let Some(data) = &response.data {
let data: serde_json::Value = serde_json::to_value(data.clone()).ok()?;
let mut val =
JsonPathFinder::new(Box::new(data), Box::new(response_data.clone())).find();
if let serde_json::Value::Array(array) = &mut val {
if array.len() == 1 {
val = array
.pop()
.expect("already checked the array had a length of 1; qed");
}
}

let val = response_data.find(data);
val.maybe_to_otel_value()
} else {
None
Expand All @@ -840,16 +829,8 @@ impl Selector for SupergraphSelector {
..
} => {
let errors = response.errors.clone();
let data: serde_json::Value = serde_json::to_value(errors).ok()?;
let mut val =
JsonPathFinder::new(Box::new(data), Box::new(response_errors.clone())).find();
if let serde_json::Value::Array(array) = &mut val {
if array.len() == 1 {
val = array
.pop()
.expect("already checked the array had a length of 1; qed");
}
}
let data: serde_json_bytes::Value = serde_json_bytes::to_value(errors).ok()?;
let val = response_errors.find(&data);

val.maybe_to_otel_value()
}
Expand Down Expand Up @@ -1088,17 +1069,7 @@ impl Selector for SubgraphSelector {
default,
..
} => if let Some(data) = &response.response.body().data {
let data: serde_json::Value = serde_json::to_value(data.clone()).ok()?;
let mut val =
JsonPathFinder::new(Box::new(data), Box::new(subgraph_response_data.clone()))
.find();
if let serde_json::Value::Array(array) = &mut val {
if array.len() == 1 {
val = array
.pop()
.expect("already checked the array had a length of 1; qed");
}
}
let val = subgraph_response_data.find(data);

val.maybe_to_otel_value()
} else {
Expand All @@ -1111,17 +1082,9 @@ impl Selector for SubgraphSelector {
..
} => {
let errors = response.response.body().errors.clone();
let data: serde_json::Value = serde_json::to_value(errors).ok()?;
let mut val =
JsonPathFinder::new(Box::new(data), Box::new(subgraph_response_error.clone()))
.find();
if let serde_json::Value::Array(array) = &mut val {
if array.len() == 1 {
val = array
.pop()
.expect("already checked the array had a length of 1; qed");
}
}
let data: serde_json_bytes::Value = serde_json_bytes::to_value(errors).ok()?;

let val = subgraph_response_error.find(&data);

val.maybe_to_otel_value()
}
Expand Down Expand Up @@ -1176,7 +1139,6 @@ mod test {
use std::sync::Arc;

use http::StatusCode;
use jsonpath_rust::JsonPathInst;
use opentelemetry::baggage::BaggageExt;
use opentelemetry::trace::SpanContext;
use opentelemetry::trace::SpanId;
Expand All @@ -1188,6 +1150,7 @@ mod test {
use opentelemetry::KeyValue;
use opentelemetry_api::StringValue;
use serde_json::json;
use serde_json_bytes::path::JsonPathInst;
use tower::BoxError;
use tracing::span;
use tracing::subscriber;
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/plugins/telemetry/config_new/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ mod test {
use std::sync::Arc;

use http::header::USER_AGENT;
use jsonpath_rust::JsonPathInst;
use opentelemetry_semantic_conventions::trace::GRAPHQL_DOCUMENT;
use opentelemetry_semantic_conventions::trace::HTTP_REQUEST_METHOD;
use opentelemetry_semantic_conventions::trace::NETWORK_PROTOCOL_VERSION;
use opentelemetry_semantic_conventions::trace::URL_PATH;
use opentelemetry_semantic_conventions::trace::USER_AGENT_ORIGINAL;
use parking_lot::Mutex;
use serde_json_bytes::path::JsonPathInst;

use crate::context::CONTAINS_GRAPHQL_ERROR;
use crate::graphql;
Expand Down
5 changes: 4 additions & 1 deletion apollo-router/tests/type_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//! Please ensure that any tests added to this file use the tokio multi-threaded test executor.
//!

use apollo_compiler::execution::JsonMap;
use apollo_router::graphql::Request;
use apollo_router::graphql::Response;
use apollo_router::plugin::test::MockSubgraph;
Expand All @@ -11,8 +10,12 @@ use apollo_router::MockedSubgraphs;
use apollo_router::TestHarness;
use serde::Deserialize;
use serde_json::json;
use serde_json_bytes::ByteString;
use serde_json_bytes::Value;
use tower::ServiceExt;

type JsonMap = serde_json_bytes::Map<ByteString, Value>;

#[derive(Deserialize)]
struct SubgraphMock {
mocks: Vec<RequestAndResponse>,
Expand Down
Loading
Loading