graphql_infra_tool 1.1.0
graphql_infra_tool: ^1.1.0 copied to clipboard
A comprehensive Flutter package providing a robust wrapper around GraphQL operations with built-in error handling, authentication, caching, and logging capabilities.
1.1.0 #
Added #
GQLInterceptor— abstract middleware hook withonRequest,onResponse, andonErrorlifecycle callbacksGQLInterceptorLink— a singleLinkthat drives a list ofGQLInterceptorinstances, sitting before auth links so retries always pick up fresh tokensGQLTokenRefreshProvider— base class for implementing proactive and reactive token refresh strategiesGQLExceptionParser— new pluggable extension point for project-level exception parsing; implementparse(dynamic rawException)and pass instances viaGQLConfig.exceptionParsersinterceptorsfield onGQLConfigto register customGQLInterceptorinstancesexceptionParsersfield onGQLConfigto register customGQLExceptionParserinstances
Removed #
GQLExceptionProvider— replaced by the more flexibleGQLExceptionParser. If you were usingGQLExceptionProvider, migrate toGQLExceptionParser(see migration guide below)exceptionProvidersfield removed fromGQLConfig
Migration Guide #
Exception parsing — before:
class MyExceptionProvider extends GQLExceptionProvider {
@override
String get errorCode => 'MY_ERROR';
@override
GQLException? createException(String errorCode, String? message, Map<String, dynamic>? extensions) {
return AppError(AppErrorModel(message: message, code: errorCode));
}
}
GQLConfig(
baseURL: '...',
exceptionProviders: [MyExceptionProvider()],
);
Exception parsing — after:
class MyExceptionParser extends GQLExceptionParser {
@override
GQLException? parse(dynamic rawException) {
if (rawException is! OperationException) return null;
if (rawException.graphqlErrors.isEmpty) return null;
final error = rawException.graphqlErrors[0];
if (error.extensions?['code'] != 'MY_ERROR') return null;
return AppError(AppErrorModel(message: error.message, code: 'MY_ERROR'));
}
}
GQLConfig(
baseURL: '...',
exceptionParsers: [MyExceptionParser()],
);
1.0.0 #
- Initial version.
1.0.1 #
Added #
- New unified
execute<T>()method for all GraphQL operations - New unified
executeList<T>()method for list operations OperationTypeenum to specify query, mutation, or subscription
Improved #
- Reduced code duplication
- Better consistency across operations
Breaking Changes #
query<T>()method - useexecute<T>()withOperationType.querymutate<T>()method - useexecute<T>()withOperationType.mutationqueryList<T>()method - useexecuteList<T>()withOperationType.querymutateList<T>()method - useexecuteList<T>()withOperationType.mutation
Migration Guide #
// Before (still works but deprecated)
final user = await client.query<User>(...);
// After (recommended)
final user = await client.execute<User>(
operation: getUserQuery,
operationType: OperationType.query,
variables: {'id': '123'},
modelParser: (json) => User.fromJson(json),
);