Skip to content

Commit

Permalink
Remove deprecated Name reexports (#877)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin authored Jul 8, 2024
1 parent 2268629 commit 71e180d
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 22 deletions.
15 changes: 15 additions & 0 deletions crates/apollo-compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## Maintenance
## Documentation-->

# [x.x.x] (unreleased) - 2024-mm-dd

## BREAKING

- **Remove deprecated `Name` reexports - [SimonSapin] in [pull/877].**
`apollo_compiler::Name` should now be imported instead of:
* `apollo_compiler::ast::Name`
* `apollo_compiler::schema::Name`
* `apollo_compiler::executable::Name`
These other paths emitted deprecation warnings in 1.0.0-beta.18 and are now removed.

[SimonSapin]: https://github.com/SimonSapin
[pull/877]: https://github.com/apollographql/apollo-rs/pull/877


# [1.0.0-beta.18](https://crates.io/crates/apollo-compiler/1.0.0-beta.18) - 2024-06-27

## BREAKING
Expand Down
4 changes: 2 additions & 2 deletions crates/apollo-compiler/src/ast/from_cst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ impl Convert for cst::Value {
}

impl Convert for cst::ObjectField {
type Target = (ast::Name, Node<ast::Value>);
type Target = (crate::Name, Node<ast::Value>);

fn convert(&self, file_id: FileId) -> Option<Self::Target> {
let name = self.name()?.convert(file_id)?;
Expand All @@ -765,7 +765,7 @@ impl Convert for cst::Name {
let loc = NodeLocation::new(file_id, self.syntax());
let token = &self.syntax().first_token()?;
let str = token.text();
debug_assert!(ast::Name::is_valid_syntax(str));
debug_assert!(crate::Name::is_valid_syntax(str));
Some(crate::Name::new(str).ok()?.with_location(loc))
}
}
4 changes: 1 addition & 3 deletions crates/apollo-compiler/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@
//! that has chaining methods for setting serialization configuration,
//! and also implements `Display` and `ToString`.
use crate::Name;
use crate::Node;

#[deprecated = "import `apollo_compiler::Name` instead"]
pub type Name = crate::Name;

pub(crate) mod from_cst;
pub(crate) mod impls;
pub(crate) mod serialize;
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! ```rust
//! use apollo_compiler::NodeLocation;
//! use apollo_compiler::Schema;
//! use apollo_compiler::ast::Name;
//! use apollo_compiler::Name;
//! use apollo_compiler::diagnostic::CliReport;
//! use apollo_compiler::diagnostic::Diagnostic;
//! use apollo_compiler::diagnostic::ToCliReport;
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/executable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub(crate) mod validation;
pub use crate::ast::Argument;
pub use crate::ast::Directive;
pub use crate::ast::DirectiveList;
pub use crate::ast::Name;
pub use crate::ast::NamedType;
pub use crate::ast::OperationType;
pub use crate::ast::Type;
Expand All @@ -29,6 +28,7 @@ pub use crate::ast::VariableDefinition;
use crate::validation::DiagnosticList;
use crate::validation::Valid;
use crate::validation::WithErrors;
pub use crate::Name;
use crate::NodeLocation;
use std::fmt;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/execution/engine.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::ast::Name;
use crate::ast::Value;
use crate::executable::Field;
use crate::executable::Selection;
Expand All @@ -18,6 +17,7 @@ use crate::schema::Type;
use crate::validation::SuspectedValidationBug;
use crate::validation::Valid;
use crate::ExecutableDocument;
use crate::Name;
use crate::Schema;
use crate::SourceMap;
use indexmap::IndexMap;
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/execution/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub struct GraphQLLocation {
#[serde(untagged)]
pub enum ResponseDataPathElement {
/// The relevant key in an object value
Field(crate::ast::Name),
Field(crate::Name),

/// The index of the relevant item in a list value
ListIndex(usize),
Expand Down
1 change: 0 additions & 1 deletion crates/apollo-compiler/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![doc = include_str!("../README.md")]
#![allow(deprecated)] // TODO: after the transition, remove this and `ast::Name`

#[macro_use]
mod macros;
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/schema/component.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ast::Name;
use crate::Name;
use crate::Node;
use crate::NodeLocation;
use std::fmt;
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub use crate::ast::DirectiveLocation;
pub use crate::ast::EnumValueDefinition;
pub use crate::ast::FieldDefinition;
pub use crate::ast::InputValueDefinition;
pub use crate::ast::Name;
pub use crate::ast::NamedType;
pub use crate::ast::Type;
pub use crate::ast::Value;
Expand All @@ -37,6 +36,7 @@ use crate::ty;
use crate::validation::DiagnosticList;
use crate::validation::Valid;
use crate::validation::WithErrors;
pub use crate::Name;

/// High-level representation of a GraphQL schema
#[derive(Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/validation/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::ast;
use crate::ast::DirectiveLocation;
use crate::ast::Name;
use crate::ast::Type;
use crate::coordinate::SchemaCoordinate;
use crate::coordinate::TypeAttributeCoordinate;
use crate::diagnostic::CliReport;
use crate::executable;
use crate::Name;
use crate::Node;
use crate::NodeLocation;
use std::fmt;
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/validation/field.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::ast;
use crate::ast::Name;
use crate::coordinate::FieldArgumentCoordinate;
use crate::coordinate::TypeAttributeCoordinate;
use crate::executable;
Expand All @@ -9,6 +8,7 @@ use crate::validation::diagnostics::DiagnosticData;
use crate::validation::DiagnosticList;
use crate::validation::OperationValidationContext;
use crate::ExecutableDocument;
use crate::Name;
use crate::Node;
use indexmap::IndexMap;

Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/validation/fragment.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::ast;
use crate::ast::Name;
use crate::ast::NamedType;
use crate::executable;
use crate::schema;
Expand All @@ -12,6 +11,7 @@ use crate::validation::OperationValidationContext;
use crate::validation::RecursionGuard;
use crate::validation::RecursionStack;
use crate::ExecutableDocument;
use crate::Name;
use crate::Node;
use std::borrow::Cow;
use std::collections::HashMap;
Expand Down
3 changes: 2 additions & 1 deletion crates/apollo-compiler/src/validation/input_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::validation::CycleError;
use crate::validation::DiagnosticList;
use crate::validation::RecursionGuard;
use crate::validation::RecursionStack;
use crate::Name;
use crate::Node;
use std::collections::HashMap;

Expand Down Expand Up @@ -150,7 +151,7 @@ pub(crate) fn validate_argument_definitions(
) {
validate_input_value_definitions(diagnostics, schema, input_values, directive_location);

let mut seen: HashMap<ast::Name, &Node<ast::InputValueDefinition>> = HashMap::new();
let mut seen: HashMap<Name, &Node<ast::InputValueDefinition>> = HashMap::new();
for input_value in input_values {
let name = &input_value.name;
if let Some(prev_value) = seen.get(name) {
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/validation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub(crate) mod union_;
pub(crate) mod value;
pub(crate) mod variable;

use crate::ast::Name;
use crate::diagnostic::CliReport;
use crate::diagnostic::Diagnostic;
use crate::diagnostic::ToCliReport;
Expand All @@ -37,6 +36,7 @@ use crate::execution::Response;
pub(crate) use crate::node::FileId;
use crate::schema::BuildError as SchemaBuildError;
use crate::schema::Implementers;
use crate::Name;
use crate::Node;
use crate::NodeLocation;
use crate::SourceMap;
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo-compiler/src/validation/selection.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::ast;
use crate::ast::Name;
use crate::ast::NamedType;
use crate::coordinate::TypeAttributeCoordinate;
use crate::executable;
Expand All @@ -12,6 +11,7 @@ use crate::schema;
use crate::validation::DiagnosticList;
use crate::validation::OperationValidationContext;
use crate::ExecutableDocument;
use crate::Name;
use crate::Node;
use apollo_parser::LimitTracker;
use indexmap::IndexMap;
Expand Down
9 changes: 5 additions & 4 deletions crates/apollo-compiler/src/validation/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::validation::RecursionGuard;
use crate::validation::RecursionLimitError;
use crate::validation::RecursionStack;
use crate::ExecutableDocument;
use crate::Name;
use crate::Node;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
Expand All @@ -17,7 +18,7 @@ pub(crate) fn validate_variable_definitions(
schema: Option<&crate::Schema>,
variables: &[Node<ast::VariableDefinition>],
) {
let mut seen: HashMap<ast::Name, &Node<ast::VariableDefinition>> = HashMap::new();
let mut seen: HashMap<Name, &Node<ast::VariableDefinition>> = HashMap::new();
for variable in variables.iter() {
super::directive::validate_directives(
diagnostics,
Expand Down Expand Up @@ -126,7 +127,7 @@ fn walk_selections<'doc>(
result
}

fn variables_in_value(value: &ast::Value) -> impl Iterator<Item = &ast::Name> + '_ {
fn variables_in_value(value: &ast::Value) -> impl Iterator<Item = &Name> + '_ {
let mut value_stack = vec![value];
std::iter::from_fn(move || {
while let Some(value) = value_stack.pop() {
Expand All @@ -143,13 +144,13 @@ fn variables_in_value(value: &ast::Value) -> impl Iterator<Item = &ast::Name> +
})
}

fn variables_in_arguments(args: &[Node<ast::Argument>]) -> impl Iterator<Item = &ast::Name> + '_ {
fn variables_in_arguments(args: &[Node<ast::Argument>]) -> impl Iterator<Item = &Name> + '_ {
args.iter().flat_map(|arg| variables_in_value(&arg.value))
}

fn variables_in_directives(
directives: &[Node<ast::Directive>],
) -> impl Iterator<Item = &ast::Name> + '_ {
) -> impl Iterator<Item = &Name> + '_ {
directives
.iter()
.flat_map(|directive| variables_in_arguments(&directive.arguments))
Expand Down

0 comments on commit 71e180d

Please sign in to comment.