Skip to main content

graphql_server2 9.0.0 copy "graphql_server2: ^9.0.0" to clipboard
graphql_server2: ^9.0.0 copied to clipboard

Base package for implementing GraphQL servers. You might prefer `package:angel3_graphql`, the fastest way to implement GraphQL backends in Dart.

Change Log #

9.0.0 #

Breaking changes in 9.0.0 #

  • Breaking: The package:graphql_server2/mirrors.dart library is removed, so the package no longer uses dart:mirrors. convertDartType, convertDartClass, objectTypeFromClassMirror, enumTypeFromClassMirror, fieldFromGetter and mirrorsFieldResolver are gone. Generate types with graphql_generator2 or define them with the graphql_schema2 helpers, and return Maps from resolvers or give fields their own resolve callbacks.
  • Breaking: A field that has no resolver, on a parent value that is not a Map, such as a model object, is reported as an error naming the field, instead of resolving to null. Pass a defaultFieldResolver to resolve such fields.
  • Breaking: No longer depends on angel3_serialize, meta or tuple. Add them to your own pubspec.yaml if you used them through this package.

To keep resolving fields from model objects instead of mirrorsFieldResolver, pass a defaultFieldResolver that reads them, for example from toJson():

var graphQL = GraphQL(
  schema,
  defaultFieldResolver: <T>(T obj, String? name, Map<String, dynamic> _) =>
      (obj as dynamic).toJson()[name] as T,
);

New in 9.0.0 #

  • package:graphql_server2/graphql_transport_ws.dart implements the graphql-transport-ws protocol of the graphql-ws library, which current clients such as Apollo Client 3 and urql use for subscriptions over WebSockets. Extend TransportWSServer with an onSubscribe that runs operations; it enforces the protocol's rules with its close codes (TransportWSCloseCode), answers pings, and stops an operation when the client completes it or the connection ends. An error of the connection, such as a binary message, closes it as an invalid message. A subscription's stream that comes after its operation was stopped is cancelled at once, on both protocols, so that its source cleans up.

Fixes in 9.0.0 #

  • Operations: A document of several operations, run without an operation name, fails with "Must provide operation name if query contains multiple operations.", where it said "This document does not define any operations.", which is now said only of a document without any.
  • Types: A custom scalar, such as angel3_graphql's Upload, can be the type of a variable, and is listed by introspection, where it was an unknown type.
  • Subscriptions: Cancelling a subscription's stream stops its source at once, where it waited for the source's next event, so a quiet source was never cancelled.
  • Subscriptions: The errors of a failed subscription event are a list of errors, where they were a list of one list.
  • subscriptions_transport_ws: RemoteClient of a StreamChannel<String>, such as a WebSocket's, reads and writes JSON, where its sink failed with a TypeError on the first message, so the protocol could not be served over text. A message that is not a JSON object with a string type is left out, where one without it threw. The end of the connection, and its errors, reach the server, which never knew the connection had ended, and a message sent after it has closed is dropped, where it was an uncaught error.
  • subscriptions_transport_ws: stop cancels an operation, as do connection_terminate and the end of the connection, where operations ran until their streams ended, and done completes, also after connection_terminate or an error of the connection, which closes the connection. A connection that ends while onConnect runs is not acknowledged, and starts no keep-alive timer. A start of an id in use stops its operation first. An invalid start is answered with an error message, where it threw, and an operation that throws, or a stream that fails, with its errors, those of a GraphQLException one by one. An event keeps its errors.
  • Scalars: A scalar field whose value is already in its serialized form, and valid, is output as it is, so a Date field accepts an ISO 8601 string, as a MapService stores dates, instead of failing with "must be DateTime". It is written as the type writes its values, so a Date has one format whatever form it came in; an enum keeps the name it was given.
  • Arguments: Arguments and variables are deserialized from their validated value, so an Int given for Float!, [Float] or a Float! input field is coerced instead of throwing a TypeError.

8.0.0 #

Breaking changes in 8.0.0 #

  • Breaking: Requires graphql_parser2 8.0.0, whose inline fragments may have no type condition.
  • Breaking: Requires graphql_schema2 8.0.0, whose validate returns a failed ValidationResult for wrongly typed input instead of throwing. Wrongly typed variables are reported as GraphQL errors.
  • Breaking: An argument given as a variable takes the variable's coerced value as is, instead of being validated and deserialized again.
  • Breaking: An omitted or null variable for an argument with a default value takes that default, instead of failing.

Fixes in 8.0.0 #

  • Unions: A field of a union type no longer throws a TypeError when its value is completed.
  • Variables: Enum variables are accepted; they failed because their Dart value was validated again as a name.
  • Variables: A null variable for a non-null argument is reported as an error naming the argument.
  • Directives: @skip and @include apply to fragment spreads and inline fragments, not only fields.
  • Directives: @skip and @include find their if argument among several arguments.
  • Fragments: An inline fragment without a type condition applies to any type.

7.0.0 #

  • Require Dart >= 3.13
  • Updated angel3_serialize to 9.0.0
  • Updated graphql_schema2 to 7.0.0
  • Updated graphql_parser2 to 7.0.0

6.5.0 #

  • Require Dart >= 3.9

6.4.1 #

  • Fix analyzer warnings

6.4.0 #

  • Require Dart >= 3.8
  • Updated lints to 6.0.0
  • Updated dependencies to the latest release

6.3.0 #

  • Require Dart >= 3.6
  • Updated lints to 5.0.0

6.2.0 #

  • Require Dart >= 3.3
  • Updated lints to 4.0.0

6.1.0 #

  • Updated lints to 3.0.0
  • Fixed linter warnings
  • Updated repository link

6.0.0 #

  • Require dart >= 3.0.x

5.0.0 #

  • Require dart >= 2.17.x

4.0.0 #

  • Require dart >= 2.16.x
  • Updated angel3_serialise to 6.x.x

3.0.0 #

  • Fixed enum conversion

  • Implemented directives

  • Implemented jsonpath directive, example:

    // you add the directive at the variable definition:
    mutation myQuery($createdId: Int! @jsonpath(path: "$.C0.create.id")) {
      // this mutation will create some object and return the new id
      C0: SomeNamespace {
          create(name: "Some object") {
            id
          }
      }
      // this mutation uses the generated $createdId from the json path directive
      C1: OtherNamespace {
          update(id: 123, relationshipId: $createdId) {
            id
          }
      }
    }
    // you can optionally declare the variable
    {
      createdId: 0 // if the jsonpath directive can't resolve a value, 
      // it will use this (0) instead
    }
    
  • Added polymorphic names: you can add an alias to a type to use with on fragments. This is nice when you have a __typename that must be unique like MyNestedType123 but you would like to use a better name when on fragments: ...on MyType

  • Updated to SDK 2.15.x

2.1.1 #

  • Fixed bug in enums

2.1.0 #

  • Upgraded from pendantic to lints linter

2.0.1 #

  • Fixed NNBD issues

2.0.0 #

  • Migrated to support Dart SDK 2.12.x NNBD
  • Rename graphql_server to graphql_server2

1.1.0 #

  • Updates for package:graphql_parser@1.2.0.
  • Now that variables are InputValueContext descendants, handle them the same way as other values in coerceArgumentValues. TLDR - Removed now-obsolete, variable-specific logic in coerceArgumentValues.
  • Pass argumentName, not fieldName, to type validations.

1.0.3 #

  • Make field resolution asynchronous.
  • Make introspection cycle-safe.
  • Thanks @deep-guarav and @micimize!

1.0.2 #

1.0.1 #

  • Fix a bug where globalVariables were not being properly passed to field resolvers.

1.0.0 #

  • Finish testing.
  • Add package:pedantic fixes.

1.0.0-rc.0 #

  • Get the Apollo support working with the latest version of subscriptions-transport-ws.

1.0.0-beta.4 #

For some reason, Pub was not including subscriptions_transport_ws.dart.

1.0.0-beta.3 #

  • Introspection on subscription types (if any).

1.0.0-beta.2 #

  • Fix bug where field aliases would not be resolved.

1.0.0-beta.1 #

  • Add (currently untested) subscription support.

1.0.0-beta #

  • First release.
7
likes
160
points
1.04k
downloads

Documentation

API reference

Publisher

verified publisherdukefirehawk.com

Weekly Downloads

Base package for implementing GraphQL servers. You might prefer `package:angel3_graphql`, the fastest way to implement GraphQL backends in Dart.

Homepage
Repository (GitHub)
View/report issues
Contributing

License

BSD-3-Clause (license)

Dependencies

collection, graphql_parser2, graphql_schema2, recase, stream_channel

More

Packages that depend on graphql_server2