Skip to content

Releases: apollographql/apollo-rs

[email protected]

04 Nov 11:10
1651b6f
Compare
Choose a tag to compare

0.1.4 - 2022-11-04

Maintenance

[email protected]

04 Nov 16:30
979a783
Compare
Choose a tag to compare

0.3.1 - 2022-11-04

Features

  • streaming lexer - Geal + goto-bus-stop, pull/115

    To help improve performance and memory usage in the lexer, we are now
    streaming all incoming tokens in the lexer implementation.

  • extend ast::*Value node conversions - SimonSapin, pull/344

    The following node types implement conversion to standard types, extracting
    their value:

    • StringValueString
    • IntValuei32
    • FloatValuef64
    • BoolValuebool

    These conversions are now also available:

    • Through the From trait, not just the Into trait
    • With borrowed nodes, not just owned

    Example:

    let node: &apollo_parser::ast::StringValue = /* something */;
    let value: String = node.clone().into(); // before
    let value = String::from(node); // now also possible

Documentation

  • example of modifying queries with parser + encoder - lrlna, pull/346
    An addition to apollo-parser's example directory encoding various parts of the AST using apollo-encoder's new TryFrom implementation. Examples include:

    • merging two queries
    • omitting certain fields in a query.

[email protected]

04 Nov 16:37
70bc2ab
Compare
Choose a tag to compare

0.3.4 - 2022-11-04

Maintenance

[email protected]

02 Nov 14:32
e72853c
Compare
Choose a tag to compare

0.3.0 - 2022-11-02

Breaking

  • compiler.parse is renamed to compiler.ast - lrlna, pull/290

    compiler.ast() returns the SyntaxTree produced by the parser and is much
    clearer method than compiler.parse().

  • selection.ty(db) now expects a db parameter - lrlna, pull/290

    As byproduct of separating compiler's query_groups into individual components.
    Selection's type can now be accessed like so:

    let ctx = ApolloCompiler::new(input);
    let top_product_fields: Vec<String> = top_products
      .iter()
      .filter_map(|field| Some(field.ty(&ctx.db)?.name()))
      .collect();
  • removes db.definitions() API - lrlna, pull/295

    db.definitions() returned a !Send value that is no longer possible with
    the ParallelDatabase implementation.

    To access HIR definitions, use db.db_definitions() and db.type_system_definitions.

Features

  • add subtype_map and is_subtype queries - lrlna/SimonSapin, pull/333

    This allows users to check whether a particular type is a subtype of another
    type. For example, in a UnionDefinition such as union SearchResult = Photo | Person, Person is a suptype of SearchResult. In an InterfaceDefinition such
    as type Business implements NamedEntity & ValuedEntity { # fields },
    Business is a subtype of NamedEntity.

  • pub compiler storage - allow database composition - lrlna, pull/328

    This allows for internal query_groups to be exported, and allows users to
    compose various databases from compiler's existing dbs and their queries.

    This is how you'd create a database with storage from apollo-compiler:

    use apollo_compiler::{database::{AstStorage, DocumentStorage}};
    
    #[salsa::database(AstStorage, DoumentStorage)]
    pub struct AnotherDatabase {
        pub storage: salsa::Storage<AnotherDatabase>,
    }

    You can also see a more detailed linting example in examples dir.

  • validate argument name uniqueness - goto-bus-stop, pull/317

    It's an error to declare or provide multiple arguments by the same name, eg:

    type Query {
      things(offset: Int!, offset: Int!): [Thing]
      # ERR: duplicate argument definition: offset
    }
    query GetThings {
      things(offset: 10, offset: 20) { id }
      # ERR: duplicate argument values: offset
    }

    This adds UniqueArgument diagnostics and checks for argument duplications in:
    field definitions, fields, directives, interfaces and directive definitions.

  • getter for directives in HIR FragmentSpread - allancalix, pull/315

    Allow accessing directives in a given FragmentSpread node in a high-level
    intermediate representation of the compiler.

  • create validation database - lrlna, pull/303

    All validation now happens in its own database, which can be accessed with
    ValidationDatabase and ValidationStorage.

  • thread-safe compiler: introduce snapshots - lrlna, pull/295 + pull/332

    Implements ParallelDatabase for RootDatabase of the compiler. This allows
    us to create snapshots that can allow users to query the database from
    multiple threads. For example:

    let input = r#"
    type Query {
      website: URL,
      amount: Int
    }
    
    scalar URL @specifiedBy(url: "https://tools.ietf.org/html/rfc3986")
    "#;
    
    let ctx = ApolloCompiler::new(input);
    let diagnostics = ctx.validate();
    for diagnostic in &diagnostics {
        println!("{}", diagnostic);
    }
    
    assert!(diagnostics.is_empty());
    
    let snapshot = ctx.snapshot();
    let snapshot2 = ctx.snapshot();
    
    let thread1 = std::thread::spawn(move || snapshot.find_object_type_by_name("Query".into()));
    let thread2 = std::thread::spawn(move || snapshot2.scalars());
    
    thread1.join().expect("object_type_by_name panicked");
    thread2.join().expect("scalars failed");
  • add description getters to compiler's HIR nodes - aschaeffer, pull/289

    Expose getters for descriptions that can be accessed for any definitions that
    support them. For example:

    let input = r#"
    "Books in a given libary"
    type Book {
      id: ID!
    }
    "#;
    
    let ctx = ApolloCompiler::new(input);
    
    let desc = ctx.db.find_object_type_by_name("Book".to_string()).unwrap().description();

Fixes

  • update parser version - goto-bus-stop, pull/331

  • unused variables return an error diagnostic - lrlna, pull/314

    We were previously returning a warning for any unused variables, it is now
    reported as an error.

Maintenance

  • split up db into several components - lrlna, pull/290

    We are splitting up the single query_group we had in our db into several
    query_groups that currently just build upon each other, and eventually could
    support more complex relationships between one another. The current structure:

    Inputs --> DocumentParser --> Definitions --> Document

    All of these query_groups make up the RootDatabase, i.e. salsa::database.

    This also allows external users to build out their own databases with
    compiler's query groups.

  • support wasm compiler target - allancalix, pull/287, issue/288

    apollo-compiler can now compile to a Wasm target with cargo check --target wasm32-unknown-unknown.

[email protected]

31 Oct 16:56
d61ca2f
Compare
Choose a tag to compare

0.3.0 - 2022-10-31 💀

BREAKING

  • remove the impl Display for generated nodes - goto-bus-stop, pull/330

    The Display impls for generated nodes returned the source text for that
    node. That's not a super common operation but it was very easy to access. It's
    also a very different operation from eg. let content: String = node.string_value().into() which returns the content of a string:
    node.string_value().to_string() returned the string as it was written in the
    source code, quotes and escapes and all.

    Now .to_string() is replaced by a .source_string() method. It allocates a
    new String (just like .to_string() did). A syntax node can represent
    multiple slices (I think to support different structures like Ropes as
    input?), so slicing the original source isn't actually possible.

Fixes

  • handle unexpected tokens in top-level document parsing - JrSchild, pull/324
    Unexpected tokens directly inside a document would break the loop in the
    parser, for example:

    @
    {
      name
    }}

    This resulted in the rest of the parsing to be skipped. An error is created
    here instead.

Maintenance

  • reduce token copying - goto-bus-stop, pull/323

    • Reduce token copying

    Since the original lexer results are not needed anymore after this step,
    we can take ownership of the tokens and errors vectors and reverse them
    in-place without making a copy. Big schemas can have 100K+ tokens so
    it's actually quite a lot of work to copy them.

    • Reduce double-clones of tokens in the parser

    Some of these clones were not necessary. In particular the .expect
    method cloned the token unconditionally (including the string inside)
    and then cloned the string again immediately afterwards. This removes
    the first clone by reordering the current.index() call to satisfy the
    borrow checker.

    The .data().to_string() clone is only used in the error case, but
    avoiding that will require more work.

[email protected]

31 Oct 16:57
8bcd9d7
Compare
Choose a tag to compare

0.3.3 - 2022-10-31 👻

Features

  • provide TryFrom for encoder types - goto-bus-stop pull/329
    Provides TryFrom impls for the apollo-encoder AST types.

    The conversion effectively assumes that the apollo-parser AST is valid and
    complete. Otherwise you get an Err, but not a very useful one, because the
    TryFrom impl doesn't know anything about its parent (so we can't show source
    code where the error originated for example).

[email protected]

03 Oct 13:33
8f05e06
Compare
Choose a tag to compare

0.2.12 - 2022-09-30

Fixes

  • unterminated string values with line terminators and unicode - lrlna, pull/320 fixes issue/318

    We were missing adding a line terminator character to the errors created by the lexer in case of a unterminated string. This showed up incidentally while dealing with unicode and the fact that it's of a different byte length than most other characters.

[email protected]

20 Sep 09:43
9935931
Compare
Choose a tag to compare

0.2.11 - 2022-09-20

Features

  • introduce a getter to parser's green nodes - lrlna, pull/295

    creates a getter to parser's underlying green nodes that make up the
    resulting, more ergonomic AST. This is handy for our compiler's use case when
    creating a thread-safe access to the AST.

Fixes

  • selection set is required for named operation definitions- lrlna, pull/301 closes issue/300

    The parser was not creating errors for missing selection sets for named
    operation definitions such as query namedQuery {. This is now correctly
    flagged as erroneous graphql.

[email protected]

19 Aug 14:25
801e1ce
Compare
Choose a tag to compare

0.3.2 - 2022-08-19

Fixes

  • trim double quotes in multilingual description encodings - lrlna

    Mutilingual descriptions failed to be encoded when containing block string
    characters. The encoder now works with block string multilingual descriptions
    such as:

    """
    котя любить дрімати в "кутку" з рослинами
    """

[email protected]

16 Aug 13:59
8ae7494
Compare
Choose a tag to compare

0.2.10 - 2022-08-16

Fixes

  • unterminated string value in list and object values - bnjjj, pull/267 & [pull/274] closes issue/266

    Create and pop errors with unterminated string values in list and object
    values. Stops infinite loop when searching for a Value in the parser.