graphql_server2 9.0.0
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.dartlibrary is removed, so the package no longer usesdart:mirrors.convertDartType,convertDartClass,objectTypeFromClassMirror,enumTypeFromClassMirror,fieldFromGetterandmirrorsFieldResolverare gone. Generate types withgraphql_generator2or define them with thegraphql_schema2helpers, and returnMaps from resolvers or give fields their ownresolvecallbacks. - 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 tonull. Pass adefaultFieldResolverto resolve such fields. - Breaking: No longer depends on
angel3_serialize,metaortuple. Add them to your ownpubspec.yamlif 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.dartimplements thegraphql-transport-wsprotocol of thegraphql-wslibrary, which current clients such as Apollo Client 3 and urql use for subscriptions over WebSockets. ExtendTransportWSServerwith anonSubscribethat 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'sUpload, 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
errorsof a failed subscription event are a list of errors, where they were a list of one list. - subscriptions_transport_ws:
RemoteClientof aStreamChannel<String>, such as a WebSocket's, reads and writes JSON, where its sink failed with aTypeErroron the first message, so the protocol could not be served over text. A message that is not a JSON object with a stringtypeis 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:
stopcancels an operation, as doconnection_terminateand the end of the connection, where operations ran until their streams ended, anddonecompletes, also afterconnection_terminateor an error of the connection, which closes the connection. A connection that ends whileonConnectruns is not acknowledged, and starts no keep-alive timer. Astartof an id in use stops its operation first. An invalidstartis answered with anerrormessage, where it threw, and an operation that throws, or a stream that fails, with its errors, those of aGraphQLExceptionone by one. An event keeps itserrors. - Scalars: A scalar field whose value is already in its serialized form, and valid, is output as it is, so a
Datefield accepts an ISO 8601 string, as aMapServicestores dates, instead of failing with "must be DateTime". It is written as the type writes its values, so aDatehas 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
Intgiven forFloat!,[Float]or aFloat!input field is coerced instead of throwing aTypeError.
8.0.0 #
Breaking changes in 8.0.0 #
- Breaking: Requires
graphql_parser28.0.0, whose inline fragments may have no type condition. - Breaking: Requires
graphql_schema28.0.0, whosevalidatereturns a failedValidationResultfor 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
nullvariable 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
TypeErrorwhen its value is completed. - Variables: Enum variables are accepted; they failed because their Dart value was validated again as a name.
- Variables: A
nullvariable for a non-null argument is reported as an error naming the argument. - Directives:
@skipand@includeapply to fragment spreads and inline fragments, not only fields. - Directives:
@skipand@includefind theirifargument among several arguments. - Fragments: An inline fragment without a type condition applies to any type.
7.0.0 #
- Require Dart >= 3.13
- Updated
angel3_serializeto9.0.0 - Updated
graphql_schema2to7.0.0 - Updated
graphql_parser2to7.0.0
6.5.0 #
- Require Dart >= 3.9
6.4.1 #
- Fix analyzer warnings
6.4.0 #
- Require Dart >= 3.8
- Updated
lintsto 6.0.0 - Updated dependencies to the latest release
6.3.0 #
- Require Dart >= 3.6
- Updated
lintsto 5.0.0
6.2.0 #
- Require Dart >= 3.3
- Updated
lintsto 4.0.0
6.1.0 #
- Updated
lintsto 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_serialiseto 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
onfragments. This is nice when you have a__typenamethat must be unique likeMyNestedType123but 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
pendantictolintslinter
2.0.1 #
- Fixed NNBD issues
2.0.0 #
- Migrated to support Dart SDK 2.12.x NNBD
- Rename
graphql_servertographql_server2
1.1.0 #
- Updates for
package:graphql_parser@1.2.0. - Now that variables are
InputValueContextdescendants, handle them the same way as other values incoerceArgumentValues. TLDR - Removed now-obsolete, variable-specific logic incoerceArgumentValues. - Pass
argumentName, notfieldName, to type validations.
1.0.3 #
- Make field resolution asynchronous.
- Make introspection cycle-safe.
- Thanks @deep-guarav and @micimize!
1.0.1 #
- Fix a bug where
globalVariableswere not being properly passed to field resolvers.
1.0.0 #
- Finish testing.
- Add
package:pedanticfixes.
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.