Skip to content

apollo-compiler@1.0.0-beta.3

Choose a tag to compare

@SimonSapin SimonSapin released this 13 Oct 16:36
· 284 commits to main since this release
58518e4

1.0.0-beta.3 - 2023-10-13

BREAKING

  • Keep source files in Arc<Map<…>> everywhere - SimonSapin, pull/696:
    Change struct fields from sources: IndexMap<FileId, Arc<SourceFile>> (in Schema) or source: Option<(FileId, Arc<SourceFile>)> (in Document, ExecutablDocument, FieldSet) to sources: SourceMap, with:
    pub type SourceMap = Arc<IndexMap<FileId, Arc<SourceFile>>>;
    Cases other than Schema still only have zero or one source when created by apollo-compiler, but it is now possible to make more sources available to diagnostics, for example when merging documents:
    Arc::make_mut(&mut doc1.sources).extend(doc2.sources.iter().map(|(k, v)| (*k, v.clone())));

Features

  • Add iteration over individual diagnostics - SimonSapin, pull/696:
    let schema = Schema::parse(input, "schema.graphql");
    if let Err(errors) = schema.validate() {
        for error in errors.iter() {
            eprintln!("{error}")
        }
    }

Fixes

  • Don’t panic in validation or omit diagnostics when a source location is missing - SimonSapin, pull/697:
    In apollo-compiler 0.11 every element of the HIR always had a source location because it always came from a parsed input file. In 1.0 source location is always optional. When a node relevant to some diagnostic does not have a source location, the diagnostic should still be emitted but its labels (each printing a bit of source code) may be missing. Essential information should therefore be in the main message, not only in labels.