- All 5 batch steps: Picking, Sorting, Clarification, Slots, Handoff - go_router navigation with step indicator - graphql_flutter client wired up (endpoint via env var) - Mock data layer swappable with real GraphQL service - Item types: normal, cold, frozen, alcohol, clarify - Storage slot assignment (cell/freezer/fridge)
32 lines
946 B
Dart
32 lines
946 B
Dart
import 'package:graphql_flutter/graphql_flutter.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
/// Configure and provide the GraphQL client.
|
|
/// Set [kGraphQLEndpoint] to your Magento GraphQL endpoint.
|
|
const String kGraphQLEndpoint = String.fromEnvironment(
|
|
'GRAPHQL_ENDPOINT',
|
|
defaultValue: 'https://your-magento-store.com/graphql',
|
|
);
|
|
|
|
Future<GraphQLClient> buildGraphQLClient() async {
|
|
await initHiveForFlutter();
|
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
final token = prefs.getString('auth_token') ?? '';
|
|
|
|
final authLink = AuthLink(getToken: () async => token.isNotEmpty ? 'Bearer $token' : '');
|
|
|
|
final httpLink = HttpLink(kGraphQLEndpoint);
|
|
|
|
final link = authLink.concat(httpLink);
|
|
|
|
return GraphQLClient(
|
|
link: link,
|
|
cache: GraphQLCache(store: HiveStore()),
|
|
);
|
|
}
|
|
|
|
ValueNotifier<GraphQLClient> buildGraphQLClientNotifier(GraphQLClient client) {
|
|
return ValueNotifier(client);
|
|
}
|