chore: Rename '_getApiToken' to 'get _token' for GraphQL API map

pull/243/head
NaiJi ✨ 2023-07-22 11:26:48 -03:00
parent 08f3258615
commit 27aaf93838
1 changed files with 4 additions and 8 deletions

View File

@ -74,13 +74,11 @@ abstract class GraphQLApiMap {
defaultHeaders: {'Accept-Language': _locale}, defaultHeaders: {'Accept-Language': _locale},
); );
final String token = _getApiToken();
final Link graphQLLink = RequestLoggingLink().concat( final Link graphQLLink = RequestLoggingLink().concat(
isWithToken isWithToken
? AuthLink( ? AuthLink(
getToken: () async => getToken: () async =>
customToken == '' ? 'Bearer $token' : customToken, customToken == '' ? 'Bearer $_token' : customToken,
).concat(httpLink) ).concat(httpLink)
: httpLink, : httpLink,
); );
@ -96,16 +94,14 @@ abstract class GraphQLApiMap {
} }
Future<GraphQLClient> getSubscriptionClient() async { Future<GraphQLClient> getSubscriptionClient() async {
final String token = _getApiToken();
final WebSocketLink webSocketLink = WebSocketLink( final WebSocketLink webSocketLink = WebSocketLink(
'ws://api.$rootAddress/graphql', 'ws://api.$rootAddress/graphql',
config: SocketClientConfig( config: SocketClientConfig(
autoReconnect: true, autoReconnect: true,
headers: token.isEmpty headers: _token.isEmpty
? null ? null
: { : {
'Authorization': 'Bearer $token', 'Authorization': 'Bearer $_token',
'Accept-Language': _locale, 'Accept-Language': _locale,
}, },
), ),
@ -119,7 +115,7 @@ abstract class GraphQLApiMap {
String get _locale => getIt.get<ApiConfigModel>().localeCode ?? 'en'; String get _locale => getIt.get<ApiConfigModel>().localeCode ?? 'en';
String _getApiToken() { String get _token {
String token = ''; String token = '';
final serverDetails = getIt<ApiConfigModel>().serverDetails; final serverDetails = getIt<ApiConfigModel>().serverDetails;
if (serverDetails != null) { if (serverDetails != null) {