Skip to content

Releases: sangria-graphql/sangria

v2.0.0-M1

28 Apr 08:32
Compare
Choose a tag to compare
v2.0.0-M1 Pre-release
Pre-release

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:

This 2.0.0-M1 release includes several changes:

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

13 Aug 16:18
Compare
Choose a tag to compare
  • 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 provide FetcherContext 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 to AstVisitor)
  • 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 Violations now implement SpecViolation which provides CATs-compliant error code and arguments.

v1.4.1

12 May 00:23
Compare
Choose a tag to compare
  • 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 the extensions field

    Before 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 default true) and addFieldsInError (by default false). You can also set both flags to true 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 replaced TrieMap-based cache implementation with ConcurrentHashMap. This change introduces potential minor performance improvements and compatibility with GraalVM native-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 flexible TransformValueNames.

  • 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 ObjectTypes 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

20 Feb 23:23
Compare
Choose a tag to compare

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 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 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

v1.3.3

03 Dec 16:57
Compare
Choose a tag to compare
  • 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 use AstSchemaBuilder.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 and relOnlyCaching methods to Fetcher (#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

31 Oct 23:43
Compare
Choose a tag to compare
  • Fix regression where variables aren't passed to query reducers (#291). Thanks to @msolomon for a quick fix!

v1.3.1

29 Oct 19:57
Compare
Choose a tag to compare
  • 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 argument origin: MatOrigin. In order to migrate, you need to adjust the signatures of affected methods and add origin: 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 to Executor.prepare, but it does not require variables 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 and DeferredFutureValue now has a method mapWithErrors. This works similar to the PartialValue, 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 returns BeforeFieldResult (instead of just a tuple) which allows you to add a MiddlewareAttachment. This attachment then can be used in resolve function via Context.attachment/Context.attachments.

v1.3.0

19 Aug 18:22
Compare
Choose a tag to compare
  • Experimental Batch Executor (#273). For more info see the "Batch Executor" section of the documentation.

  • Allow Violations and UserFacingErrors to be handled by custom exception handler (#252).

    Refactored exception handling mechanism:

    • Now it is able to handle Violations as well as UserFacingErrors.
    • 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 the resolve 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.

  • 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 an InputDocument instead of just sangria.ast.Value.
    • Added RuleBasedQueryValidator.validateInputDocument that validates InputDocument against the schema.
    • InputDocument.to provide a convenient way to deserialize/materialize an input document based on the FromInput type-class.
    • Improved a lot of validation messages related to input value validations.
  • 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 and DefaultAstSchemaBuilder.resolveField has changed. You need to add extensions: 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

17 Jun 20:31
Compare
Choose a tag to compare
  • Added new middleware traits MiddlewareFromScalar and MiddlewareToScalar. 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

18 May 19:14
Compare
Choose a tag to compare
  • 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.