Releases: sangria-graphql/sangria
v2.0.0-M1
From https://github.com/sangria-graphql-org/sangria/releases/tag/v2.0.0-M1
This is the first milestone release of the 2.x series and the first Sangria release to support Scala 2.13.
Many of Sangria's modules (for marshalling and streaming integrations, etc.) are also now available for 2.13:
- https://github.com/sangria-graphql-org/macro-visit/releases/tag/v0.1.2
- https://github.com/sangria-graphql-org/sangria-argonaut/releases/tag/v1.0.1
- https://github.com/sangria-graphql-org/sangria-circe/releases/tag/v1.3.0
- https://github.com/sangria-graphql-org/sangria-ion/releases/tag/v2.0.0
- https://github.com/sangria-graphql-org/sangria-marshalling-api/releases/tag/v1.0.4
- https://github.com/sangria-graphql-org/sangria-marshalling-testkit/releases/tag/v1.0.2
- https://github.com/sangria-graphql-org/sangria-monix/releases/tag/v2.0.0
- https://github.com/sangria-graphql-org/sangria-spray-json/releases/tag/v1.0.2
- https://github.com/sangria-graphql-org/sangria-streaming-api/releases/tag/v1.0.1
This 2.0.0-M1 release includes several changes:
- Schemas now support descriptions.
- Some deprecated introspection fields have been removed.
- Directives are now allowed on variable definitions.
- There's a new
MappedAbstractType
transformation. - There are a number of changes (mostly trivial or to tests) that were needed to support Scala 2.13.
This milestone release is intended primarily to unblock adopters who are migrating to Scala 2.13, and is not guaranteed to be binary compatible with the eventual 2.x series. While these changes are well-tested, this is a pre-release milestone; please use with care and report any issues you come across.
v1.4.2
- Removed
InterfaceMustHaveImplementationValidationRule
validation rule (spec change) (#379). Since its introduction in previous release, it caused some issues (to sangria users as well users of other implementations). So it was removed from the GraphQL spec and sangria for now. - Exposed more contextual information to a fetcher, including fetcher cache (#377). Fetcher now can be created with a set of new helper methods
*WithContext
which provideFetcherContext
as an argument to fetch functions. AstSchemaMaterializer
now re-creates existing field argument types (thus able to use newly created input types)- Added visitor helpers in
AstNode
(they just delegate all functionality toAstVisitor
) - More minor improvements for better compatibility with GraalVM
native-image
. - Continued work on GraphQL CATs (Compatibility Acceptance Tests). Most recent changes and validation scenarios were added. Some
Violation
s now implementSpecViolation
which provides CATs-compliant errorcode
and arguments.
v1.4.1
-
Added support for
extend schema
in SDL (spec change) (#362). It adds following syntax in the SDL:extend schema @extraDirective { mutation: MutationType }
-
Ambiguity with null variable values and default values (spec change) (#359).
-
Add optional 'extensions' entry to errors (spec change) (#358).
CAUTION: breaking change. All additional error object fields that were provided via
HandledException
are now added to theextensions
fieldBefore v1.4.1:
{ "data": { "books": null }, "errors": [{ "message": "Can't access the database :'(", "path": ["books"], "locations": [{"line": 3, "column": 11}], "errorCode": "DATABASE_DOWN", "mitigationStrategy": "Panic!" }] }
After v1.4.1:
{ "data": { "books": null }, "errors": [{ "message": "Can't access the database :'(", "path": ["books"], "locations": [{"line": 3, "column": 11}], "extensions": { "errorCode": "DATABASE_DOWN", "mitigationStrategy": "Panic!" } }] }
For backward-compatibility,
HandledException
now provides 2 additional fields:addFieldsInExtensions
(by defaulttrue
) andaddFieldsInError
(by defaultfalse
). You can also set both flags totrue
in order to provide a migration path for the client applications. -
Ensure interface has at least 1 concrete type (spec change) (#360). It is potentially a minor breaking change. If you have non-implemented interfaces in your schema, you can temporary remove
InterfaceMustHaveImplementationValidationRule
schema validation rule. -
Added a small
Cache
abstraction and replacedTrieMap
-based cache implementation withConcurrentHashMap
. This change introduces potential minor performance improvements and compatibility with GraalVMnative-image
. -
Added
toAst
helper for different schema elements, like fields, enum values and types (#367) -
Added macro setting to transform enum values' names with a macro setting (#350). Big thanks to @fehu for this contribution! The
UppercaseValues
macro setting is now deprecated in favour of more flexibleTransformValueNames
. -
Fixed typo in
BeforeFieldResult
field name (#363). Big thanks to @Codier for this contribution! -
Adjusted
KnownTypeNames
validation to not validate SDL definitions because they are validated in the schema materializer (#354). -
Added option to disable parsing of AST locations and comments (#357)
-
Don't allow
ObjectType
s derived from case classes to overwrite each other (#345) Big thanks to @simonsaffer for this contribution! -
Improved query parsing performance by optimizing the AST location tracking (#351). Big thanks to @guymers for this contribution!
-
Fixed new line tracking when parsing block-strings
-
Ast schema builder now considers
additionalTypes
when it validates the type extensions -
Updated
sangria-marshalling-api
to version 1.0.3 (should be backwards compatible with v1.0.0).
v1.4.0
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 toQueryParser
.
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 syntax type 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 | Types extend 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 deprecated type 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
Document
s (#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
AstNode
s 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 thePosition
and holds additional field:sourceId
.- Introduced
AggregateSourceMapper
and improvedDocument
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.).
- Different schema elements retain the information about SDL
-
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
DeriveObjectSetting
s (#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 introducedInputTypeResolver
/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
v1.3.3
-
Added support for string-based descriptions in SDL and implement most recent SDL-related changes (#303, #304, #305) (spec change). Breaking change for all SDL users. The type, field and enum value descriptions are now handled differently in the SDL.
Old format (comment-based):
# This is a description # of the `Foo` type. type Foo implements Bar { # another description one: Type }
New format (string-based):
""" This is a description of the `Foo` type. """ type Foo implements Bar { "another description" one: Type }
Migration path: by default (and after the update) only new description format is used. The old comment-based format still will be supported for several versions. In order to enable description handling in the old format, please override
DefaultAstSchemaBuilder.useLegacyCommentDescriptions
or useAstSchemaBuilder.defaultWithLegacyCommentDescriptions
. -
Added block string support (#260, #301) (spec change). Here is an example of the new multi-line string syntax:
mutation { sendEmail(message: """ Hello, World! Yours, GraphQL. """) }
-
Added
relOnly
andrelOnlyCaching
methods toFetcher
(#293). Thanks to @kuppuswamy for this contribution! -
Fixed a validation of nested InputObjectType with same property names (#292).
-
Improved performance of
Document.hashCode
which had a big influence on performance of the AST-based schema builder.
v1.3.2
v1.3.1
-
High-level API for SDL-based schema materialization (#288). It provides much more simple and robust API for building an executable schema based on SDL definitions. For more info see "High-level SDL-based Schema Builder" section of the documentation.
As a part of this feature, new functionality was introduced in
AstSchemaBuilder
which provides even more flexibility for schema materialization.Minor breaking change: most of the methods in
AstSchemaBuilder
got new argumentorigin: MatOrigin
. In order to migrate, you need to adjust the signatures of affected methods and addorigin: MatOrigin
argument. -
Prepared queries without known variables (#281, #277). Huge thanks to @msolomon for making this contribution! This feature adds
QueryReducerExecutor.reduceQueryWithoutVariables
. In its signature it is similar toExecutor.prepare
, but it does not requirevariables
and designed to validate and execute query reducers for queries that are being analyzed ahead of time (e.g. in the context of persistent queries). -
Ability to provide a partial error for deferred values (#290).
DeferredValue
andDeferredFutureValue
now has a methodmapWithErrors
. This works similar to thePartialValue
, so you can still have a successful result and at the same time indicate errors that happened during deferred value resolution. -
Ability to provide additional values from Middleware (#289).
beforeField
now returnsBeforeFieldResult
(instead of just a tuple) which allows you to add aMiddlewareAttachment
. This attachment then can be used in resolve function viaContext.attachment
/Context.attachments
.
v1.3.0
-
Experimental Batch Executor (#273). For more info see the "Batch Executor" section of the documentation.
-
Allow
Violation
s andUserFacingError
s to be handled by custom exception handler (#252).Refactored exception handling mechanism:
- Now it is able to handle
Violation
s as well asUserFacingError
s. HandledException
is now able to capture multiple errors and additional AST node positions.- Since it is now a standalone class, it would be easier to expand on error handling in future.
Minor breaking change. It's just a small syntax change. Migration strategy:
// Before val exceptionHandler: Executor.ExceptionHandler = { case (m, ...) ⇒ ... }) // After val exceptionHandler = ExceptionHandler { case (m, ...) ⇒ ... }
ExceptionHandler
is now a standalone class that allows you to provide following handlers:onException
- all unexpected exceptions coming from theresolve
functions (behaves exactly like in earlier versions)onViolation
- handles violations (things like validation errors, argument/variable coercion, etc.)onUserFacingError
- handles standard sangria errors (errors like invalid operation name, max query depth, etc.)
For more info see the updated "Custom ExceptionHandler" section of the documentation.
- Now it is able to handle
-
Improved input document validation and deserialization (#272). For more info see "Input Document Validation" section of the documentation and updated "Query AST Marshalling" section. Improvements include:
- Added
InputDocument
which is used in validation, materialization, etc. - New macros
gqlInpDoc
/graphqlInputDoc
that produces anInputDocument
instead of justsangria.ast.Value
. - Added
RuleBasedQueryValidator.validateInputDocument
that validatesInputDocument
against the schema. InputDocument.to
provide a convenient way todeserialize
/materialize
an input document based on theFromInput
type-class.- Improved a lot of validation messages related to input value validations.
- Added
-
Add support for leading vertical bar in union types and directive definitions (#253) (spec change).
-
Fixed infinite loop on invalid queries in OverlappingFields (#266, #238).
-
Information about type extensions is now available in the field resolve function builder (#267). Minor breaking change. The signature of
DefaultAstSchemaBuilder.buildField
andDefaultAstSchemaBuilder.resolveField
has changed. You need to addextensions: Vector[ast.TypeExtensionDefinition]
as a second argument. -
Fixed directive definition rendering in query renderer (#274). Thanks to @alexeygolev for this contribution!
-
Built-in scalars will now only be added to the schema if they are used (#271, #270). Thanks to @jlawrienyt for this contribution!
-
Improve error message when an appropriate implementation of an abstract type cannot be found (#259).
v1.2.2
- Added new middleware traits
MiddlewareFromScalar
andMiddlewareToScalar
. They provide a way to transform all scalar values from middleware (#249, #248). This have some advantages since middleware can be disable, chained together and has access to context information. Huge thanks to @BjRo and @Axxiss for helping with the feature design and implementation! - Added new middleware trait
MiddlewareExtension
(#256). It provides an easy way to add extensions from middleware. - Improved error message for
All fields within a Type should have unique names!
(#247). It now includes type and field information. - Fixed helper methods for operation lookup in
ast.Document
.
v1.2.1
- Fixed
MeasureQueryDepth
reducer not keeping the largest depth found (#245, #246). Big thanks @Eluinhost for this contribution! - Easier way to create
Args
(#243). Big thanks @vishalkuo for this contribution! - More options to render a schema (#241). This improvement is especially useful for apps that use relay modern.