Skip to content

Releases: apollographql/apollo-rs

[email protected]

10 May 12:01
13be234
Compare
Choose a tag to compare

Features

  • add SyntaxTree::token_limit - SimonSapin, pull/525
    This enables finding out how many tokens were present in a succesful parse,
    which can be useful to choose where to set the limit.

  • add Definition::kind() -> &str and Definition::is_executable_definition() - goto-bus-stop, pull/535
    These are new methods on the Definition AST node. kind() returns the kind
    of definition (eg. "ScalarTypeExtension") and is_executable_definition()
    returns true for operation definitions and fragment definitions.

Fixes

  • handle escape sequences when reading string contents - goto-bus-stop, pull/541
    The String::from(StringValue) implementation now turns escape sequences like
    \n and \u2764 into their literal characters.

[email protected]

13 Apr 11:33
ff2df97
Compare
Choose a tag to compare

0.5.1 - 2023-04-13

Fixes

  • remove recursion in field parsing - goto-bus-stop, pull/519
    The selection::selection_set parser already supports parsing multiple fields.
    This removes recursion from field parsing, reducing the risk of stack
    overflow on queries with many fields.

[email protected]

13 Apr 11:34
Compare
Choose a tag to compare

0.5.1 - 2023-04-13

Featues

  • add Clone impl to encoder types - zackangelo, pull/515
    Consistently derive Clone on all encoder types.

[email protected]

13 Apr 13:22
b296ae1
Compare
Choose a tag to compare

0.8.0 - 2023-04-13

BREAKING

There is now an API to set parser's token limits via apollo-compiler. To
accommodate an additional limit, we changed the API to set several limits
simultaneously.

let op = r#"
    query {
        a {
            a {
                a {
                    a
                }
            }
        }
    }
"#;
let mut compiler = ApolloCompiler::new().token_limit(22).recursion_limit(10);
compiler.add_executable(op, "op.graphql");
let errors = compiler.db.syntax_errors();

assert_eq!(errors.len(), 1)

by lrlna in pull/512

Features

Fixes

[email protected]

03 Apr 18:02
fd067de
Compare
Choose a tag to compare

0.7.2 - 2023-04-03

Features

Fixes

  • db.interfaces() checks pre-computed hir for interfaces first, by lrlna in de4baea

[email protected]

28 Mar 11:03
020bbfb
Compare
Choose a tag to compare

0.7.0 - 2023-03-27

Important: X breaking changes below, indicated by BREAKING

This release encompasses quite a few validation rules the compiler was missing.
Here, we primarily focused on field and directive validation, as well as supporting
multi-file diagnostics.

BREAKING

  • find_operation query now mimics spec's
    getOperation
    functionality and returns the anonymous operation if None is specified for
    operation name; by lrlna in pull/447

  • Extensions are applied implicitly in HIR by SimonSapin in pull/481,
    pull/482, and pull/484

    Adding a GraphQL type extension is similar to modifying a type.
    This release makes a number of breaking changes to API signatures and behavior
    so these modifications are accounted for implicitly.
    For example, interface.field(name) may now return a field
    from an extend interface extension or from the original interface definition.
    We expect that most callers don’t need to tell the difference.
    For callers that do, methods with a self_ prefix are added (or renamed)
    for accessing components of a definition itself as opposed to added by an extension.

    Renamed methods:
    - SchemaDefinition::root_operation_type_definitionself_root_operations
    - ObjectTypeDefinition::fields_definitionself_fields
    - InterfaceTypeDefinition::fields_definitionself_fields
    - InputObjectTypeDefinition::input_fields_definitionself_fields
    - ObjectTypeDefinition::implements_interfacesself_implements_interfaces
    - InterfaceTypeDefinition::implements_interfacesself_implements_interfaces
    - UnionTypeDefinition::union_membersself_members
    - EnumTypeDefinition::enum_values_definitionself_values
    - TypeDefiniton::directivesself_directives
    - SchemaDefiniton::directivesself_directives
    - EnumTypeDefiniton::directivesself_directives
    - UnionTypeDefiniton::directivesself_directives
    - ObjectTypeDefiniton::directivesself_directives
    - ScalarTypeDefiniton::directivesself_directives
    - InterfaceTypeDefiniton::directivesself_directives
    - InputObjectTypeDefiniton::directivesself_directives

    Method names freed by the above are now redefined with new behaviour and
    signature, and include extensions:
    - ObjectTypeDefinition::implements_interfaces() -> impl Iterator
    - InterfaceTypeDefinition::implements_interfaces() -> impl Iterator
    - TypeDefiniton::directives() -> impl Iterator
    - SchemaDefiniton::directives() -> impl Iterator
    - EnumTypeDefiniton::directives() -> impl Iterator
    - UnionTypeDefiniton::directives() -> impl Iterator
    - ObjectTypeDefiniton::directives() -> impl Iterator
    - ScalarTypeDefiniton::directives() -> impl Iterator
    - InterfaceTypeDefiniton::directives() -> impl Iterator
    - InputObjectTypeDefiniton::directives() -> impl Iterator

    Methods whose behaviour and signature changed, where each method now returns the
    name of an object type instead of its definition:
    - SchemaDefinition::query() -> Option<&str>
    - SchemaDefinition::mutation() -> Option<&str>
    - SchemaDefinition::subscription() -> Option<&str>

    Methods whose behaviour changed to consider extensions, and no signature has changed
    - TypeDefinition::field(name) -> Option
    - ObjectTypeDefinition::field(name) -> Option
    - InterfaceTypeDefinition::field(name) -> Option

    New methods which take extensions into consideration:
    - SchemaDefinition::root_operations() -> impl Iterator
    - ObjectTypeDefinition::fields() -> impl Iterator
    - ObjectTypeDefinition::implements_interface(name) -> bool
    - InterfaceTypeDefinition::fields() -> impl Iterator
    - InterfaceTypeDefinition::implements_interface(name) -> bool
    - InputObjectTypeDefinition::self_fields() -> &[_]
    - InputObjectTypeDefinition::fields() -> impl Iterator
    - InputObjectTypeDefinition::field(name) -> Option
    - UnionTypeDefinition::members() -> impl Iterator
    - UnionTypeDefinition::has_member(name) -> bool
    - EnumTypeDefinition::values() -> impl Iterator
    - EnumTypeDefinition::value(name) -> Option

    New methods for every type which have a directives method:
    - directive_by_name(name) -> Option
    - directives_by_name(name) -> impl Iterator

Features

Fixes

Maintenance

[email protected]

17 Feb 12:29
e54dff9
Compare
Choose a tag to compare

Features

  • new ast::Definition methods - goto-bus-stop, pull/456
    When working with Definition nodes, you can use the .name() method to get the name of a definition, regardless of its kind. For schema definitions, it returns None.
    You can use .is_extension_definition() to check if a definition node is an extension.

Fixes

  • fix token order around type names - goto-bus-stop, issue/362, pull/443

    type Query {
      field: Int # comment
    }

    Previously, the whitespace and comment around the Int type name would end up before the type name in the parse tree. This would mess up the location information for the Int type name. Now this is fixed.

  • fix spans after parsing unexpected tokens - goto-bus-stop, issue/325, pull/446

    Location information for all nodes after an unexpected token was incorrect. It's better now, though still imperfect: lexing errors still have this problem.

  • fix ignored token positioning in the AST - goto-bus-stop, pull/445

    This makes spans for all nodes more specific, not including ignored tokens after the node. When ignored tokens are consumed, they are first stored separately, and then added to the AST just before the next node is started. This way ignored tokens are always inside the outermost possible node, and therefore all individual nodes will have spans that only contain that node and not more.

    The most obvious effect of this is that diagnostics now point to the exact thing they are about, instead of a bunch of whitespace :)

[email protected]

17 Feb 12:30
328aa58
Compare
Choose a tag to compare

BREAKING

Features

  • make FromError public - Geal, pull/453

    In the TryFrom implementations for apollo-parser types, the error type was not public, so you could not wrap conversion errors in your own error types or name it in return values. Now you can use apollo_encoder::FromError.

[email protected]

18 Jan 15:27
3af152c
Compare
Choose a tag to compare

0.6.0 - 2023-01-18

This release has a few breaking changes as we try to standardise APIs across the
compiler. We appreciate your patience with these changes. If you run into trouble, please open an issue.

BREAKING

  • Rename compiler.create_* methods to compiler.add_*, SimonSapin in 412
  • Rename schema to type_system for compiler.add_ and compiler.update_
    methods, SimonSapin in 413
  • Unify ty, type_def and kind namings in HIR, lrlna in 415
    • in Type struct impl: ty() --> type_def()
    • in TypeDefinition struct impl: ty() --> kind()
    • in FragmentDefinition struct impl: ty() --> type_def()
    • in RootOperationTypeDefinition struct: operation_type field -->
      operation_ty

Features

  • FileIds are unique per process, SimonSapin in 405
  • Type alias compiler.snapshot() return type to Snapshot, SimonSapin in
    410
  • Introduce a type system high-level intermediate representation (HIR) as input
    to the compiler, SimonSapin in 407

Fixes

  • Use #[salsa::transparent] for find_* queries, i.e. not caching query results, lrlna in 403

Maintenance

Documentation

[email protected]

04 Jan 16:47
d91fabc
Compare
Choose a tag to compare

0.5.0 - 2023-01-04

Highlights

Multi-file support

You can now build a compiler from multiple sources. This is especially useful
when various parts of a GraphQL document are coming in at different times and
need to be analysed as a single context. Or, alternatively, you are looking to
lint or validate multiple GraphQL files part of the same context in a given directory or workspace.

The are three different kinds of sources:

  • document: for when a source is composed of executable and type system
    definitions, or you're uncertain of definitions types
  • schema: for sources with type system definitions or extensions
  • executable: for sources with executable definitions/GraphQL queries

You can add a source with create_ and update it with update_, for example
create_document and update_document. Here is an example:

    let schema = r#"
type Query {
  dog: Dog
}

type Dog {
  name: String!
}
    "#;

    let query = r#"
query getDogName {
  dog {
    name
  }
}

# duplicate name, should show up in diagnostics
query getDogName {
  dog {
    owner {
      name
    }
  }
}
    "#;
    let updated_schema = r#"
type Query {
  dog: Dog
}

type Dog {
  name: String!
  owner: Human
}

type Human {
  name: String!
}
    "#;
    let mut compiler = ApolloCompiler::new();
    let schema_id = compiler.create_schema(schema, "schema.graphl");
    let executable_id = compiler.create_executable(query, "query.graphql");
    compiler.update_schema(updated_schema, schema_id);

For more elaborate examples, please refer to multi_source_validation and
file_watcher examples in the examples dir.

We look forward to your feedback on this feature, should you be using it.

Completed in pull/368 in collaboration with goto-bus-stop, SimonSapin and
lrlna.

BREAKING

  • Remove UUID helpers and related UUID APIs from database by SimonSapin in
    pull/391
  • Merge DocumentDatabase trait into HIRDatabase by SimonSapin in
    pull/394
  • Replace hir::Definition enum with hir::TypeSystemDefinitions struct by
    SimonSapin in pull/395
  • db.type_system_definitions returns a TypeSystemDefinitions by SimonSapin
    in pull/395
  • Remove db.db_definitions, find_definition_by_name and
    find_type_system_definition_by_name by SimonSapin in pull/395
  • Remove queries returning type extensions, instead type definitions in the HIR
    contain extension information by SimonSapin in pull/387

Features

  • db.fragments, db.object_types, db.scalars, db.enums, db.unions,
    db.interfaces, db.input_objects, and db.directive_definitions return
    name-indexed maps by SimonSapin in pull/387