Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop string documents #565

Merged
merged 2 commits into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const String readRepositories = r'''

Then create a `QueryOptions` object:

> **NB:** for `documentNode` - Use our built-in help function - `gql(query)` to convert your document string to **ASTs** `documentNode`.
> **NB:** for `document` - Use our built-in help function - `gql(query)` to convert your document string to **ASTs** `document`.

In our case, we need to pass `nRepositories` variable and the document name is `readRepositories`.

Expand All @@ -119,7 +119,7 @@ In our case, we need to pass `nRepositories` variable and the document name is `
const int nRepositories = 50;

final QueryOptions options = QueryOptions(
documentNode: gql(readRepositories),
document: gql(readRepositories),
variables: <String, dynamic>{
'nRepositories': nRepositories,
},
Expand Down Expand Up @@ -166,7 +166,7 @@ Then instead of the `QueryOptions`, for mutations we will `MutationOptions`, whi
// ...

final MutationOptions options = MutationOptions(
documentNode: gql(addStar),
document: gql(addStar),
variables: <String, dynamic>{
'starrableId': repositoryID,
},
Expand Down Expand Up @@ -201,15 +201,15 @@ if (isStarred) {
### AST documents

> We are deprecating `document` and recommend you update your application to use
`documentNode` instead. `document` will be removed from the api in a future version.
`document` instead. `document` will be removed from the api in a future version.

For example:

```dart
// ...

final MutationOptions options = MutationOptions(
documentNode: gql(addStar),
document: gql(addStar),
variables: <String, dynamic>{
'starrableId': repositoryID,
},
Expand Down Expand Up @@ -238,7 +238,7 @@ import 'package:gql/add_star.ast.g.dart' as add_star;
// ...

final MutationOptions options = MutationOptions(
documentNode: add_star.document,
document: add_star.document,
variables: <String, dynamic>{
'starrableId': repositoryID,
},
Expand Down
23 changes: 11 additions & 12 deletions packages/graphql/example/bin/main.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'dart:io' show stdout, stderr, exit;

import 'package:args/args.dart';
import 'package:gql_http_link/gql_http_link.dart';
import 'package:gql_link/gql_link.dart';
import 'package:graphql/client.dart';

import './graphql_operation/mutations/mutations.dart';
import './graphql_operation/queries/readRepositories.dart';

// to run the example, create a file ../local.dart with the content:
// const String YOUR_PERSONAL_ACCESS_TOKEN =
// '<YOUR_PERSONAL_ACCESS_TOKEN>';
Expand All @@ -15,17 +18,13 @@ ArgResults argResults;

// client - create a graphql client
GraphQLClient client() {
final HttpLink _httpLink = HttpLink(
uri: 'https://api.github.com/graphql',
);

final AuthLink _authLink = AuthLink(
// ignore: undefined_identifier
getToken: () async => 'Bearer $YOUR_PERSONAL_ACCESS_TOKEN',
final Link _link = HttpLink(
'https://api.github.com/graphql',
defaultHeaders: {
'Authorization': 'Bearer $YOUR_PERSONAL_ACCESS_TOKEN',
},
);

final Link _link = _authLink.concat(_httpLink);

return GraphQLClient(
cache: InMemoryCache(),
link: _link,
Expand All @@ -39,7 +38,7 @@ void query() async {
const int nRepositories = 50;

final QueryOptions options = QueryOptions(
documentNode: gql(readRepositories),
document: gql(readRepositories),
variables: <String, dynamic>{
'nRepositories': nRepositories,
},
Expand Down Expand Up @@ -71,7 +70,7 @@ void starRepository(String repositoryID) async {
final GraphQLClient _client = client();

final MutationOptions options = MutationOptions(
documentNode: gql(addStar),
document: gql(addStar),
variables: <String, dynamic>{
'starrableId': repositoryID,
},
Expand Down Expand Up @@ -104,7 +103,7 @@ void removeStarFromRepository(String repositoryID) async {
final GraphQLClient _client = client();

final MutationOptions options = MutationOptions(
documentNode: gql(removeStar),
document: gql(removeStar),
variables: <String, dynamic>{
'starrableId': repositoryID,
},
Expand Down
4 changes: 3 additions & 1 deletion packages/graphql/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ environment:
sdk: ">=2.6.0 <3.0.0"

dependencies:
args:
args:
gql_link: ^0.2.3
gql_http_link: ^0.2.7
graphql:
path: ..

9 changes: 0 additions & 9 deletions packages/graphql/lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,3 @@ export 'package:graphql/src/core/query_options.dart';
export 'package:graphql/src/core/query_result.dart';
export 'package:graphql/src/exceptions/exceptions.dart';
export 'package:graphql/src/graphql_client.dart';
export 'package:graphql/src/link/auth/link_auth.dart';
export 'package:graphql/src/link/error/link_error.dart';
export 'package:graphql/src/link/fetch_result.dart';
export 'package:graphql/src/link/http/link_http.dart';
export 'package:graphql/src/link/link.dart';
export 'package:graphql/src/link/operation.dart';
export 'package:graphql/src/link/web_socket/link_web_socket.dart';
export 'package:graphql/src/socket_client.dart';
export 'package:graphql/src/websocket/messages.dart';
3 changes: 0 additions & 3 deletions packages/graphql/lib/internal.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export 'package:graphql/src/utilities/helpers.dart';

export 'package:graphql/src/core/observable_query.dart';

export 'package:graphql/src/link/operation.dart';
export 'package:graphql/src/link/fetch_result.dart';
Loading