sangria v1.4.0 Release Notes

Release Date: 2018-02-20 // over 4 years ago
  • The v1.4.0 has a lot of improvements and minor changes, in particular around SDL parsing and materialization. Although some of these changes are minor breaking changes , they can be divided in following 2 categories:

    • ๐Ÿ”จ Simple routine refactorings with updated method signatures. For example, most of the method signatures in AstSchemaBuilder are updated and now include more information (type extensions in particular). In all of these cases, issues will manifest themselves as compilation errors and can be fixed by simple signature updates.
    • โšก๏ธ GraphQL query and SDL syntax updates. Based on the feedback from #308 and other sources, extra attention was put in ensuring that syntax is either backward compatible or an option is available to enable support for a legacy GraphQL syntax. These options can be enabled through new ParserConfig which can be provided to QueryParser.

    If you are facing unexpected issues with migration to the new Sangria version, please let us know by creating a new GH issue.

    ๐Ÿ”„ Changes:

    ๐Ÿ†• New "implements" syntax (old syntax can be enabled via ParserConfig.legacyImplementsInterface) (#337) (spec change). Example:

    # old syntax type User implements Node, Profile { id: ID!}# new syntaxtype User implements Node & Profile { id: ID!}
    

    ๐Ÿ‘ All of the SDL types now support type extensions (#337) (spec change). Previously only object types supported this feature. Some examples:

    extend type Foo implements ExtraInterface1 & ExtraInterface2 { extraField: Int}extend interface Bar @extraDirective { extraField: Int}extend input Baz { extraField: Int = 123 }extend enum Color { "the best color" MAGENTA}extend union Test @extraDirective = More | Typesextend scalar Date @extraDirective
    

    All SDL type definitions are now allowed to have empty field/value/member lists (#337) (spec change). Examples of now valid syntax:

    type User union Pet enum Color
    

    All of the appropriate checks are now implemented as a SchemaValidationRule (instead of being part of the syntax).

    ๐Ÿ—„ Moreover, old syntax for this is now deprecated and can be enabled with ParserConfig.legacyEmptyFields. Example of the old syntax:

    # don't do it! it is now deprecatedtype User {} 
    

    โž• Add experimental support for parsing variable definitions in fragments (#313). A primary goal of it is to enable the experimentation. The support for this syntax needs to be explicitly enabled via ParserConfig. Here is how new syntax looks like:

    query q () { ...a}fragment a on t ($size: Int = 0) { f(size: $size) }
    

    ๐Ÿ‘Œ Improved AST location handling and support for multi-source AST Documents (#343). These improvements might be quite helpful for recently discussed "import" functionality where the schema SDL is defined in multiple files. Improvements include:

    • Different schema elements retain the information about SDL AstNodes that were used to create them (in addition to the directives). This might be quite helpful in multiple scenarios. It was already used to greatly improve the quality of the error messages.
    • AstLocation now replaces the Position and holds additional field: sourceId.

    - Introduced AggregateSourceMapper and improved Document merge. It is now possible to show proper error messages and source locations even for AST that was parsed from different sources (files, URLs, etc.).

    A lot of improvement to the schema validation (#312, #315). All of the validations are now implemented as SchemaValidationRule (no in-place runtime checks anymore). This can be quite helpful if you, for instance, need to customize the validation rules or disable the validations altogether.

    ๐Ÿ—„ Validate literals in a single rule with finer precision (#314). This generalizes the "arguments of correct type" and "default values of correct type" to a single rule "values of correct type" which has been re-written to rely on a traversal rather than the utility function isValidLiteralValue. isValidLiteralValue is now deprecated.

    ๐Ÿ‘ AstSchemaMaterializer now fully supports all of the new type extensions (#309) .

    SchemaComparator is improved and now includes information about "dangerous" changes (#335).

    Simplify Unknown Args Validation (#316).

    โž• Added new validation rule SingleFieldSubscriptions (#254) (spec change).

    Resolve type info for fragment spreads (#278). Big thanks to @jonas for this contribution!

    ๐Ÿ‘ Allow to rename, describe and set default arguments using DeriveObjectSettings (#339). Big thanks to @fehu for this contribution!

    ๐Ÿ‘ป Replaced Exception with Throwable to match all possible results of Future.failed (#329, #327). Big thanks to @lgmyrek for this contribution!

    ๐ŸŽ‰ Initialize symbols before checking their annotations (#317). This will improve derive* macros in same edge-cases. Big thanks to @dragos for this contribution!

    โž• Added support for rendering SDL with legacy comment-based descriptions (#334). You can use it with SchemaFilter.default.withLegacyCommentDescriptions.

    ๐Ÿ‘Œ Improved ResolverBasedAstSchemaBuilder and introduced InputTypeResolver/OutputTypeResolver.

    โšก๏ธ Updated sangria-marshalling-api to version 1.0.1 (should be backwards compatible with v1.0.0)

    Other minor improvements coming from the reference implementation (#336, #311).

    โœ‚ Removed previously deprecated methods:

    • SchemaRenderer.renderIntrospectionSchema
    • AstVisitor.visitAst