Skip to content

Commit 3a938df

Browse files
authored
change type signature for impl ariadne::Cache (#960)
* change type signature for impl ariadne::Cache<FileId> fn fetch() and fn display() changed signatures in the latest patch release of ariadne (0.51.0). * `fn fetch(&mut self, file_id: &FileId) -> Result<&ariadne::Source, Box<dyn fmt::Debug + '_>>` --> `fn fetch(&mut self, file_id: &FileId) -> Result<&ariadne::Source, impl fmt::Debug>` * `fn display<'a>(&self, file_id: &'a FileId) -> Option<Box<dyn fmt::Display + 'a>> ` --> `fn display<'a>(&self, file_id: &'a FileId) -> Option<impl fmt::Display + 'a>`
1 parent ac13e99 commit 3a938df

File tree

123 files changed

+569
-548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+569
-548
lines changed

crates/apollo-compiler/CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1717
## Maintenance
1818
## Documentation-->
1919

20+
# [1.2x.x] (unreleased) - 2025-mm-dd
21+
## Fixes
22+
23+
- **Update `ariadne` trait implementations - [lrlna], [pull/960]**
24+
`[email protected]` release changed their type signature for `ariadne::Cache` trait, which required an update to `apollo-compiler`'s implementation of `ariadne::Cache<FileId>`.
25+
26+
This release also had a slight change to path formatting, so if you had any snapshots in your tests, you can expect a change from this:
27+
```
28+
Error: `typeFragment1` contains too much nesting
29+
╭─[overflow.graphql:11:11]
30+
```
31+
32+
to this (notice the extra white space around the file path):
33+
```
34+
Error: `typeFragment1` contains too much nesting
35+
╭─[ overflow.graphql:11:11 ]
36+
```
37+
38+
[lrlna]: https://github.com/lrlna
39+
2040
# [1.27.0](https://crates.io/crates/apollo-compiler/1.26.0) - 2025-03-04
2141

2242
## Features

crates/apollo-compiler/src/diagnostic.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ struct Cache<'a>(&'a SourceMap);
283283
impl ariadne::Cache<FileId> for Cache<'_> {
284284
type Storage = String;
285285

286-
fn fetch(&mut self, file_id: &FileId) -> Result<&ariadne::Source, Box<dyn fmt::Debug + '_>> {
286+
fn fetch(&mut self, file_id: &FileId) -> Result<&ariadne::Source, impl fmt::Debug> {
287287
struct NotFound(FileId);
288288
impl fmt::Debug for NotFound {
289289
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -296,28 +296,29 @@ impl ariadne::Cache<FileId> for Cache<'_> {
296296
static EMPTY: OnceLock<ariadne::Source> = OnceLock::new();
297297
Ok(EMPTY.get_or_init(|| ariadne::Source::from(String::new())))
298298
} else {
299-
Err(Box::new(NotFound(*file_id)))
299+
Err(NotFound(*file_id))
300300
}
301301
}
302302

303-
fn display<'a>(&self, file_id: &'a FileId) -> Option<Box<dyn fmt::Display + 'a>> {
304-
if *file_id != FileId::NONE {
305-
struct Path(Arc<SourceFile>);
306-
impl fmt::Display for Path {
307-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
308-
self.0.path().display().fmt(f)
303+
fn display<'a>(&self, file_id: &'a FileId) -> Option<impl fmt::Display + 'a> {
304+
enum Path {
305+
SourceFile(Arc<SourceFile>),
306+
NoSourceFile,
307+
}
308+
impl fmt::Display for Path {
309+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
310+
match self {
311+
Path::SourceFile(source_file) => source_file.path().display().fmt(f),
312+
Path::NoSourceFile => f.write_str("(no source file)"),
309313
}
310314
}
315+
}
316+
317+
if *file_id != FileId::NONE {
311318
let source_file = self.0.get(file_id)?;
312-
Some(Box::new(Path(source_file.clone())))
319+
Some(Path::SourceFile(source_file.clone()))
313320
} else {
314-
struct NoSourceFile;
315-
impl fmt::Display for NoSourceFile {
316-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
317-
f.write_str("(no source file)")
318-
}
319-
}
320-
Some(Box::new(NoSourceFile))
321+
Some(Path::NoSourceFile)
321322
}
322323
}
323324
}

crates/apollo-compiler/test_data/diagnostics/0001_duplicate_operatoin_names.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Error: the operation `getName` is defined multiple times in the document
2-
╭─[0001_duplicate_operatoin_names.graphql:5:7]
2+
╭─[ 0001_duplicate_operatoin_names.graphql:5:7 ]
33
44
1 │ query getName {
55
│ ───┬───

crates/apollo-compiler/test_data/diagnostics/0002_multiple_anonymous_operations.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Error: anonymous operation cannot be selected when the document contains other operations
2-
╭─[0002_multiple_anonymous_operations.graphql:1:1]
2+
╭─[ 0002_multiple_anonymous_operations.graphql:1:1 ]
33
44
1 │ ╭─▶ query {
55
┆ ┆
@@ -10,7 +10,7 @@ Error: anonymous operation cannot be selected when the document contains other o
1010
│ Help: GraphQL requires operations to be named if the document has more than one
1111
───╯
1212
Error: anonymous operation cannot be selected when the document contains other operations
13-
╭─[0002_multiple_anonymous_operations.graphql:5:1]
13+
╭─[ 0002_multiple_anonymous_operations.graphql:5:1 ]
1414
1515
5 │ ╭─▶ mutation {
1616
┆ ┆

crates/apollo-compiler/test_data/diagnostics/0003_anonymous_and_named_operation.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Error: anonymous operation cannot be selected when the document contains other operations
2-
╭─[0003_anonymous_and_named_operation.graphql:1:1]
2+
╭─[ 0003_anonymous_and_named_operation.graphql:1:1 ]
33
44
1 │ ╭─▶ query {
55
┆ ┆
@@ -10,7 +10,7 @@ Error: anonymous operation cannot be selected when the document contains other o
1010
│ Help: GraphQL requires operations to be named if the document has more than one
1111
───╯
1212
Error: the required argument `Mutation.addPet(name:)` is not provided
13-
╭─[0003_anonymous_and_named_operation.graphql:6:3]
13+
╭─[ 0003_anonymous_and_named_operation.graphql:6:3 ]
1414
1515
6 │ ╭─▶ addPet {
1616
┆ ┆

crates/apollo-compiler/test_data/diagnostics/0004_subscription_with_multiple_root_fields.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Error: subscription `sub` can only have one root field
2-
╭─[0004_subscription_with_multiple_root_fields.graphql:1:1]
2+
╭─[ 0004_subscription_with_multiple_root_fields.graphql:1:1 ]
33
44
1 │ ╭─▶ subscription sub {
55
┆ ┆

crates/apollo-compiler/test_data/diagnostics/0005_subscription_with_multiple_root_fields_in_fragment_spreads.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Error: subscription `sub` can only have one root field
2-
╭─[0005_subscription_with_multiple_root_fields_in_fragment_spreads.graphql:1:1]
2+
╭─[ 0005_subscription_with_multiple_root_fields_in_fragment_spreads.graphql:1:1 ]
33
44
1 │ ╭─▶ subscription sub {
55
┆ ┆

crates/apollo-compiler/test_data/diagnostics/0006_subscription_with_multiple_root_fields_in_inline_fragments.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Error: subscription `sub` can only have one root field
2-
╭─[0006_subscription_with_multiple_root_fields_in_inline_fragments.graphql:1:1]
2+
╭─[ 0006_subscription_with_multiple_root_fields_in_inline_fragments.graphql:1:1 ]
33
44
1 │ ╭─▶ subscription sub {
55
┆ ┆

crates/apollo-compiler/test_data/diagnostics/0007_operation_with_undefined_variables.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
Error: variable `$undefinedVariable` is not defined
2-
╭─[0007_operation_with_undefined_variables.graphql:3:12]
2+
╭─[ 0007_operation_with_undefined_variables.graphql:3:12 ]
33
44
3 │ first: $undefinedVariable
55
│ ─────────┬────────
66
│ ╰────────── not found in this scope
77
───╯
88
Error: variable `$offset` is not defined
9-
╭─[0007_operation_with_undefined_variables.graphql:5:15]
9+
╭─[ 0007_operation_with_undefined_variables.graphql:5:15 ]
1010
1111
5 │ offset: $offset
1212
│ ───┬───
1313
│ ╰───── not found in this scope
1414
───╯
1515
Error: variable `$keyword` is not defined
16-
╭─[0007_operation_with_undefined_variables.graphql:6:23]
16+
╭─[ 0007_operation_with_undefined_variables.graphql:6:23 ]
1717
1818
6 │ keywords: ["a", $keyword]
1919
│ ────┬───

crates/apollo-compiler/test_data/diagnostics/0008_operation_with_undefined_variables_in_inline_fragment.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Error: variable `$value` is not defined
2-
╭─[0008_operation_with_undefined_variables_in_inline_fragment.graphql:5:25]
2+
╭─[ 0008_operation_with_undefined_variables_in_inline_fragment.graphql:5:25 ]
33
44
5 │ price(setPrice: $value)
55
│ ───┬──

0 commit comments

Comments
 (0)