Skip to content

Commit

Permalink
Update to apollo-compiler 1.25.0 stable release (#6556)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin authored Jan 17, 2025
1 parent fab4214 commit 817e878
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 70 deletions.
30 changes: 10 additions & 20 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"

[[package]]
name = "apollo-compiler"
version = "1.0.0-beta.24"
version = "1.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71153ad85c85f7aa63f0e0a5868912c220bb48e4c764556f5841d37fc17b0103"
checksum = "2d810db7b42773a4082426bcd58658cb9b311c5b74febd255130a9dcfc13109d"
dependencies = [
"ahash",
"apollo-parser",
Expand Down Expand Up @@ -245,9 +245,9 @@ dependencies = [

[[package]]
name = "apollo-parser"
version = "0.8.3"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b64257011a999f2e22275cf7a118f651e58dc9170e11b775d435de768fad0387"
checksum = "c8f05cbc7da3c2e3bb2f86e985aad5f72571d2e2cd26faf8caa7782131576f84"
dependencies = [
"memchr",
"rowan",
Expand Down Expand Up @@ -470,9 +470,9 @@ dependencies = [

[[package]]
name = "apollo-smith"
version = "0.14.0"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d89479524886fdbe62b124d3825879778680e0147304d1a6d32164418f8089a2"
checksum = "95a04f64d4d4f0048201967b8064257de212ab240fd74e2b153691b39b0e8721"
dependencies = [
"apollo-compiler",
"apollo-parser",
Expand All @@ -499,9 +499,9 @@ checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"

[[package]]
name = "ariadne"
version = "0.4.1"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44055e597c674aef7cb903b2b9f6e4cba1277ed0d2d61dae7cd52d7ffa81f8e2"
checksum = "31beedec3ce83ae6da3a79592b3d8d7afd146a5b15bb9bb940279aced60faa89"
dependencies = [
"concolor",
"unicode-width",
Expand Down Expand Up @@ -4041,15 +4041,6 @@ version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"

[[package]]
name = "memoffset"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
dependencies = [
"autocfg",
]

[[package]]
name = "memory-stats"
version = "1.2.0"
Expand Down Expand Up @@ -5584,13 +5575,12 @@ dependencies = [

[[package]]
name = "rowan"
version = "0.15.15"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a58fa8a7ccff2aec4f39cc45bf5f985cec7125ab271cf681c279fd00192b49"
checksum = "417a3a9f582e349834051b8a10c8d71ca88da4211e4093528e36b9845f6b5f21"
dependencies = [
"countme",
"hashbrown 0.14.5",
"memoffset",
"rustc-hash",
"text-size",
]
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.24"
apollo-parser = "0.8.3"
apollo-smith = "0.14.0"
apollo-compiler = "1.25.0"
apollo-parser = "0.8.4"
apollo-smith = "0.15.0"
async-trait = "0.1.77"
hex = { version = "0.4.3", features = ["serde"] }
http = "0.2.11"
Expand Down
6 changes: 4 additions & 2 deletions apollo-federation/src/operation/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use apollo_compiler::collections::IndexSet;
use apollo_compiler::name;
use apollo_compiler::parser::Parser;
use apollo_compiler::schema::Schema;
use apollo_compiler::ExecutableDocument;

Expand Down Expand Up @@ -29,8 +30,9 @@ macro_rules! assert_normalized {
pub(super) fn parse_schema_and_operation(
schema_and_operation: &str,
) -> (ValidFederationSchema, ExecutableDocument) {
let (schema, executable_document) =
apollo_compiler::parse_mixed_validate(schema_and_operation, "document.graphql").unwrap();
let (schema, executable_document) = Parser::new()
.parse_mixed_validate(schema_and_operation, "document.graphql")
.unwrap();
let executable_document = executable_document.into_inner();
let schema = ValidFederationSchema::new(schema).unwrap();
(schema, executable_document)
Expand Down
7 changes: 4 additions & 3 deletions apollo-federation/src/query_graph/path_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ where
mod tests {
use std::sync::Arc;

use apollo_compiler::parser::Parser;
use apollo_compiler::ExecutableDocument;
use petgraph::stable_graph::NodeIndex;
use petgraph::visit::EdgeRef;
Expand All @@ -585,9 +586,9 @@ mod tests {
fn parse_schema_and_operation(
schema_and_operation: &str,
) -> (ValidFederationSchema, ExecutableDocument) {
let (schema, executable_document) =
apollo_compiler::parse_mixed_validate(schema_and_operation, "document.graphql")
.unwrap();
let (schema, executable_document) = Parser::new()
.parse_mixed_validate(schema_and_operation, "document.graphql")
.unwrap();
let executable_document = executable_document.into_inner();
let schema = ValidFederationSchema::new(schema).unwrap();
(schema, executable_document)
Expand Down
4 changes: 2 additions & 2 deletions apollo-federation/src/subgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Subgraph {
.schema_definition
.make_mut()
.directives
.push(defaults.applied_link_directive().into());
.push(defaults.applied_link_directive());
defaults
}
};
Expand All @@ -136,7 +136,7 @@ impl Subgraph {
.schema_definition
.make_mut()
.directives
.push(defaults.applied_link_directive().into());
.push(defaults.applied_link_directive());
defaults
}
};
Expand Down
4 changes: 2 additions & 2 deletions apollo-router/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl IntoGraphQLErrors for FederationErrorBridge {
}
}

impl IntoGraphQLErrors for Vec<apollo_compiler::execution::GraphQLError> {
impl IntoGraphQLErrors for Vec<apollo_compiler::response::GraphQLError> {
fn into_graphql_errors(self) -> Result<Vec<Error>, Self> {
Ok(self
.into_iter()
Expand Down Expand Up @@ -550,7 +550,7 @@ impl IntoGraphQLErrors for ParseErrors {
/// Collection of schema validation errors.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub(crate) struct ValidationErrors {
pub(crate) errors: Vec<apollo_compiler::execution::GraphQLError>,
pub(crate) errors: Vec<apollo_compiler::response::GraphQLError>,
}

impl ValidationErrors {
Expand Down
8 changes: 4 additions & 4 deletions apollo-router/src/graphql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ mod visitor;
use std::fmt;
use std::pin::Pin;

use apollo_compiler::execution::GraphQLError as CompilerExecutionError;
use apollo_compiler::execution::ResponseDataPathElement;
use apollo_compiler::response::GraphQLError as CompilerExecutionError;
use apollo_compiler::response::ResponseDataPathSegment;
use futures::Stream;
use heck::ToShoutySnakeCase;
pub use request::Request;
Expand Down Expand Up @@ -233,10 +233,10 @@ impl From<CompilerExecutionError> for Error {
let elements = path
.into_iter()
.map(|element| match element {
ResponseDataPathElement::Field(name) => {
ResponseDataPathSegment::Field(name) => {
JsonPathElement::Key(name.as_str().to_owned(), None)
}
ResponseDataPathElement::ListIndex(i) => JsonPathElement::Index(i),
ResponseDataPathSegment::ListIndex(i) => JsonPathElement::Index(i),
})
.collect();
Some(Path(elements))
Expand Down
23 changes: 6 additions & 17 deletions apollo-router/src/graphql/response.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(missing_docs)] // FIXME
use std::time::Instant;

use apollo_compiler::response::ExecutionResponse;
use bytes::Bytes;
use serde::Deserialize;
use serde::Serialize;
Expand Down Expand Up @@ -245,25 +246,13 @@ impl IncrementalResponse {
}
}

impl From<apollo_compiler::execution::Response> for Response {
fn from(response: apollo_compiler::execution::Response) -> Response {
let apollo_compiler::execution::Response {
errors,
data,
extensions,
} = response;
impl From<ExecutionResponse> for Response {
fn from(response: ExecutionResponse) -> Response {
let ExecutionResponse { errors, data } = response;
Self {
errors: errors.into_graphql_errors().unwrap(),
data: match data {
apollo_compiler::execution::ResponseData::Object(map) => {
Some(serde_json_bytes::Value::Object(map))
}
apollo_compiler::execution::ResponseData::Null => {
Some(serde_json_bytes::Value::Null)
}
apollo_compiler::execution::ResponseData::Absent => None,
},
extensions,
data: data.map(serde_json_bytes::Value::Object),
extensions: Default::default(),
label: None,
path: None,
has_next: None,
Expand Down
19 changes: 11 additions & 8 deletions apollo-router/src/introspection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,26 @@ impl IntrospectionCache {
}

fn execute_introspection(schema: &spec::Schema, doc: &ParsedDocument) -> graphql::Response {
let schema = schema.api_schema();
let api_schema = schema.api_schema();
let operation = &doc.operation;
let variable_values = Default::default();
match apollo_compiler::execution::coerce_variable_values(
schema,
match apollo_compiler::request::coerce_variable_values(
api_schema,
operation,
&variable_values,
) {
Ok(variable_values) => apollo_compiler::execution::execute_introspection_only_query(
schema,
)
.and_then(|variable_values| {
apollo_compiler::introspection::partial_execute(
api_schema,
&schema.implementers_map,
&doc.executable,
operation,
&variable_values,
)
.into(),
}) {
Ok(response) => response.into(),
Err(e) => {
let error = e.into_graphql_error(&doc.executable.sources);
let error = e.to_graphql_error(&doc.executable.sources);
graphql::Response::builder().error(error).build()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expression: response
{
"errors": [
{
"message": "Value \"C does not exist in \"InputEnum\" enum.",
"message": "Value \"C\" does not exist in \"InputEnum\" enum.",
"locations": [
{
"line": 1,
Expand Down
11 changes: 4 additions & 7 deletions apollo-router/src/spec/query/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,13 +569,10 @@ mod tests {
def: &ast::Field,
) -> Result<Option<ast::Field>, BoxError> {
Ok(field(self, field_def, def)?.map(|mut new| {
new.directives.push(
ast::Directive {
name: apollo_compiler::name!("added"),
arguments: Vec::new(),
}
.into(),
);
new.directives.push(ast::Directive {
name: apollo_compiler::name!("added"),
arguments: Vec::new(),
});
new
}))
}
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.24"
apollo-compiler = "1.25.0"
apollo-router = { path = "../../../apollo-router" }
async-trait = "0.1"
tower = { version = "0.4", features = ["full"] }
Expand Down

0 comments on commit 817e878

Please sign in to comment.