Repository navigation
Typed options and cache helpers, scalar_mapping with imports, fetch_schema - #7
Merged
Merged
Conversation
Each operation file gets functions building package:graphql options with typed variables and the generated parser as parserFn, so QueryResult.parsedData and ObservableQuery results are typed: getUserQueryOptions, getUserWatchQueryOptions, renameMutationOptions, userChangedSubscriptionOptions. Query extensions also get typed read<Op>/write<Op> cache helpers.
- scalar_mapping entries can be `{type, import, converter}`; the import is
added to types.dart and operation files, the converter is used on fields,
list elements, variables and root fields
- Mapped types without a converter are read with fromJson and written with
toJson unless they are JSON-native
- strict_scalars fails generation (SCH401) for custom scalars without a
mapping
- Fix: variables of a scalar mapped to DateTime were sent as DateTime objects
`dart run flutter_graphql_codegen:fetch_schema` downloads the schema from schema_endpoint (new config key) with schema_headers into schema_url, with --config, --endpoint, --output and --header overrides.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes for 2.3.0. No breaking changes: everything is new API or opt-in.
Typed options for package:graphql (the Dart counterpart of
TypedDocumentNode)<op>QueryOptions/<op>WatchQueryOptions(queries),<op>MutationOptions,<op>SubscriptionOptions. They take typed variables plus fetch and error policies, polling, optimistic results and mutationupdate/onCompleted/onError, and setparserFnto the generated parser, soparsedDataandObservableQueryresults are typedvariables:named if all are optional, absent if there are noneread<Op>(typed, null on cache miss) andwrite<Op>(raw data) for the normalized cachescalar_mapping with imports
{type, import, converter}; the short form keeps working. The import goes intotypes.dartand the operation files (withunused_importignored). The converter is used for fields, list elements (json_serializable applies field converters to elements), variables and root fieldsfromJson/toJsonunless JSON-nativestrict_scalars:SCH401for custom scalars without a mappingDateTimewere sent as rawDateTimeobjectsfetch_schema
dart run flutter_graphql_codegen:fetch_schemadownloads fromschema_endpoint(new key) withschema_headersintoschema_url. Overrides:--config,--endpoint,--output,--header(repeatable). Exit codes: 1 = download failed, 64 = usage errorargsTests
mappedvariant (a converter, a fromJson/toJson type, the short form, nullable list elements), and the smoke client exercises typedquery/mutate/subscribe,watchQuerytyping and a cache write/read round trip