From f226c9021dd8931ce7345e643455fc7a6e1d72b1 Mon Sep 17 00:00:00 2001 From: Tuanny Harumi Date: Wed, 16 Jun 2021 18:49:16 -0300 Subject: [PATCH 1/3] Accept and return gql context in execute method --- lib/client.dart | 7 +++++-- lib/schema/graphql_response.dart | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/client.dart b/lib/client.dart index 6616d86c..5f1c8459 100644 --- a/lib/client.dart +++ b/lib/client.dart @@ -42,14 +42,16 @@ class ArtemisClient { /// Executes a [GraphQLQuery], returning a typed response. Future> execute( - GraphQLQuery query, - ) async { + GraphQLQuery query, { + Context context = const Context(), + }) async { final request = Request( operation: Operation( document: query.document, operationName: query.operationName, ), variables: query.getVariablesMap(), + context: context, ); final response = await _link.request(request).first; @@ -57,6 +59,7 @@ class ArtemisClient { return GraphQLResponse( data: response.data == null ? null : query.parse(response.data ?? {}), errors: response.errors, + context: response.context, ); } diff --git a/lib/schema/graphql_response.dart b/lib/schema/graphql_response.dart index 9ce3f315..17ef157f 100644 --- a/lib/schema/graphql_response.dart +++ b/lib/schema/graphql_response.dart @@ -12,9 +12,13 @@ class GraphQLResponse { /// If this response has any error. bool get hasErrors => errors != null && errors!.isNotEmpty; + /// The [Context] of the [Response] + final Context? context; + /// Instantiates a GraphQL response. const GraphQLResponse({ this.data, this.errors, + this.context, }); } From 62c1eb3f87287651884c641fda37b02b292dd56f Mon Sep 17 00:00:00 2001 From: Tuanny Harumi Date: Thu, 17 Jun 2021 16:02:42 -0300 Subject: [PATCH 2/3] Add context to client stream --- lib/client.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/client.dart b/lib/client.dart index 5f1c8459..d3a30f27 100644 --- a/lib/client.dart +++ b/lib/client.dart @@ -65,19 +65,22 @@ class ArtemisClient { /// Streams a [GraphQLQuery], returning a typed response stream. Stream> stream( - GraphQLQuery query, - ) { + GraphQLQuery query, { + Context context = const Context(), + }) { final request = Request( operation: Operation( document: query.document, operationName: query.operationName, ), variables: query.getVariablesMap(), + context: context, ); return _link.request(request).map((response) => GraphQLResponse( data: response.data == null ? null : query.parse(response.data ?? {}), errors: response.errors, + context: response.context, )); } From 6365901f9464817249b4b181ada9d8896a36a481 Mon Sep 17 00:00:00 2001 From: Tuanny Harumi Date: Thu, 17 Jun 2021 16:04:07 -0300 Subject: [PATCH 3/3] Bump version and add changelog --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dea91038..7b2114b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 7.0.0-beta.14 + +- Support gql context in client's execute and stream methods + ## 7.0.0-beta.13 - fix for https://github.com/comigor/artemis/issues/177 diff --git a/pubspec.yaml b/pubspec.yaml index 221beb32..ed69c418 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: artemis -version: 7.0.0-beta.13 +version: 7.0.0-beta.14 description: Build dart types from GraphQL schemas and queries (using Introspection Query). homepage: https://github.com/comigor/artemis