diff --git a/examples/starwars/lib/episode/hero_query.dart b/examples/starwars/lib/episode/hero_query.dart index aed2e6497..d96115e2c 100644 --- a/examples/starwars/lib/episode/hero_query.dart +++ b/examples/starwars/lib/episode/hero_query.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:gql/language.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import './episode.dart'; @@ -13,7 +12,7 @@ class HeroForEpisode extends StatelessWidget { Widget build(BuildContext context) { return Query( options: QueryOptions( - documentNode: parseString(r''' + documentNode: gql(r''' query HeroForEpisode($ep: Episode!) { hero(episode: $ep) { __typename diff --git a/examples/starwars/lib/main.dart b/examples/starwars/lib/main.dart index 0208106a5..f6c312740 100644 --- a/examples/starwars/lib/main.dart +++ b/examples/starwars/lib/main.dart @@ -8,10 +8,11 @@ import './reviews/review_page.dart'; import './reviews/review_page_list.dart'; String get host { - if (Platform.isAndroid) + if (Platform.isAndroid) { return '10.0.2.2'; - else // for iOS simulator + } else { return 'localhost'; + } } final String GRAPHQL_ENDPOINT = 'http://$host:3000/graphql'; diff --git a/examples/starwars/lib/reviews/review.dart b/examples/starwars/lib/reviews/review.dart index 82fce56e6..35680a8dc 100644 --- a/examples/starwars/lib/reviews/review.dart +++ b/examples/starwars/lib/reviews/review.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import 'package:meta/meta.dart'; import '../episode/episode.dart'; diff --git a/examples/starwars/lib/reviews/review_page_list.dart b/examples/starwars/lib/reviews/review_page_list.dart index aa34d5047..7b1f83391 100644 --- a/examples/starwars/lib/reviews/review_page_list.dart +++ b/examples/starwars/lib/reviews/review_page_list.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:starwars_app/reviews/review_subscription.dart' show DisplayReviews; -import 'package:gql/language.dart'; class PagingReviews extends StatelessWidget { static const BottomNavigationBarItem navItem = BottomNavigationBarItem( @@ -14,7 +13,7 @@ class PagingReviews extends StatelessWidget { Widget build(BuildContext context) { return Query( options: QueryOptions( - documentNode: parseString(r''' + documentNode: gql(r''' query Reviews($page: Int!) { reviews(page: $page) { page diff --git a/packages/graphql/example/bin/main.dart b/packages/graphql/example/bin/main.dart index 0863ddef1..2d224c90a 100644 --- a/packages/graphql/example/bin/main.dart +++ b/packages/graphql/example/bin/main.dart @@ -5,8 +5,6 @@ import 'package:graphql/client.dart'; import './graphql_operation/mutations/mutations.dart'; import './graphql_operation/queries/readRepositories.dart'; -import 'package:gql/language.dart'; - // to run the example, create a file ../local.dart with the content: // const String YOUR_PERSONAL_ACCESS_TOKEN = // ''; @@ -41,7 +39,7 @@ void query() async { const int nRepositories = 50; final QueryOptions options = QueryOptions( - documentNode: parseString(readRepositories), + documentNode: gql(readRepositories), variables: { 'nRepositories': nRepositories, }, @@ -73,7 +71,7 @@ void starRepository(String repositoryID) async { final GraphQLClient _client = client(); final MutationOptions options = MutationOptions( - documentNode: parseString(addStar), + documentNode: gql(addStar), variables: { 'starrableId': repositoryID, }, @@ -106,7 +104,7 @@ void removeStarFromRepository(String repositoryID) async { final GraphQLClient _client = client(); final MutationOptions options = MutationOptions( - documentNode: parseString(removeStar), + documentNode: gql(removeStar), variables: { 'starrableId': repositoryID, }, diff --git a/packages/graphql/lib/src/core/query_manager.dart b/packages/graphql/lib/src/core/query_manager.dart index 0cee710fd..73c224b17 100644 --- a/packages/graphql/lib/src/core/query_manager.dart +++ b/packages/graphql/lib/src/core/query_manager.dart @@ -1,22 +1,18 @@ import 'dart:async'; -import 'package:graphql/src/exceptions/exceptions.dart'; -import 'package:meta/meta.dart'; - -import 'package:graphql/src/core/query_options.dart'; -import 'package:graphql/src/core/query_result.dart'; -import 'package:graphql/src/core/observable_query.dart'; - -import 'package:graphql/src/scheduler/scheduler.dart'; - -import 'package:graphql/src/link/link.dart'; -import 'package:graphql/src/link/operation.dart'; -import 'package:graphql/src/link/fetch_result.dart'; - import 'package:graphql/src/cache/cache.dart'; import 'package:graphql/src/cache/normalized_in_memory.dart' show NormalizedInMemoryCache; import 'package:graphql/src/cache/optimistic.dart' show OptimisticCache; +import 'package:graphql/src/core/observable_query.dart'; +import 'package:graphql/src/core/query_options.dart'; +import 'package:graphql/src/core/query_result.dart'; +import 'package:graphql/src/exceptions/exceptions.dart'; +import 'package:graphql/src/link/fetch_result.dart'; +import 'package:graphql/src/link/link.dart'; +import 'package:graphql/src/link/operation.dart'; +import 'package:graphql/src/scheduler/scheduler.dart'; +import 'package:meta/meta.dart'; class QueryManager { QueryManager({ diff --git a/packages/graphql/lib/src/core/raw_operation_data.dart b/packages/graphql/lib/src/core/raw_operation_data.dart index 9f226a354..76c7e12f5 100644 --- a/packages/graphql/lib/src/core/raw_operation_data.dart +++ b/packages/graphql/lib/src/core/raw_operation_data.dart @@ -3,11 +3,10 @@ import 'dart:convert' show json; import 'package:gql/ast.dart'; import 'package:gql/language.dart'; -import 'package:http/http.dart'; - -import 'package:graphql/src/utilities/get_from_ast.dart'; import 'package:graphql/src/link/http/link_http_helper_deprecated_stub.dart' if (dart.library.io) 'package:graphql/src/link/http/link_http_helper_deprecated_io.dart'; +import 'package:graphql/src/utilities/get_from_ast.dart'; +import 'package:http/http.dart'; class RawOperationData { RawOperationData({ diff --git a/packages/graphql_flutter/example/lib/fetchmore/main.dart b/packages/graphql_flutter/example/lib/fetchmore/main.dart index 47916122b..f9c18e5ce 100644 --- a/packages/graphql_flutter/example/lib/fetchmore/main.dart +++ b/packages/graphql_flutter/example/lib/fetchmore/main.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:gql/language.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import '../graphql_operation/queries/readRepositories.dart' as queries; @@ -83,7 +82,7 @@ class _MyHomePageState extends State { ), Query( options: QueryOptions( - documentNode: parseString(queries.searchRepositories), + documentNode: gql(queries.searchRepositories), variables: { 'nRepositories': nRepositories, 'query': _searchQuery, diff --git a/packages/graphql_flutter/example/lib/graphql_bloc/bloc.dart b/packages/graphql_flutter/example/lib/graphql_bloc/bloc.dart index e066d8bff..6f62e89aa 100644 --- a/packages/graphql_flutter/example/lib/graphql_bloc/bloc.dart +++ b/packages/graphql_flutter/example/lib/graphql_bloc/bloc.dart @@ -73,8 +73,8 @@ class Bloc { Future _mutateToggleStar(Repo repo) async { final MutationOptions _options = MutationOptions( - documentNode: parseString( - repo.viewerHasStarred ? mutations.removeStar : mutations.addStar), + documentNode: + gql(repo.viewerHasStarred ? mutations.removeStar : mutations.addStar), variables: { 'starrableId': repo.id, }, diff --git a/packages/graphql_flutter/example/lib/graphql_widget/main.dart b/packages/graphql_flutter/example/lib/graphql_widget/main.dart index 1e53010e0..0047c8234 100644 --- a/packages/graphql_flutter/example/lib/graphql_widget/main.dart +++ b/packages/graphql_flutter/example/lib/graphql_widget/main.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:gql/language.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import '../graphql_operation/mutations/mutations.dart' as mutations; @@ -96,7 +95,7 @@ class _MyHomePageState extends State { ), Query( options: QueryOptions( - documentNode: parseString(queries.readRepositories), + documentNode: gql(queries.readRepositories), variables: { 'nRepositories': nRepositories, }, @@ -175,8 +174,7 @@ class StarrableRepository extends StatelessWidget { Widget build(BuildContext context) { return Mutation( options: MutationOptions( - documentNode: - parseString(starred ? mutations.removeStar : mutations.addStar), + documentNode: gql(starred ? mutations.removeStar : mutations.addStar), update: (Cache cache, QueryResult result) { if (result.hasException) { print(result.exception);