copyWith method

GraphQLRequest<T> copyWith({
  1. String? document,
  2. String? apiName,
  3. Map<String, String>? headers,
  4. APIAuthorizationType<AmplifyAuthProvider>? authorizationMode,
  5. Map<String, dynamic>? variables,
  6. String? decodePath,
  7. ModelType<Model>? modelType,
})

Creates a copy of this request with the given fields replaced with the new values. If no new value is given, the old value is used.

final original = ModelQueries.list(
  Blog.classType,
);
final modified = original.copyWith(
  document: yourCustomQuery,
);

Useful in advanced scenarios where you want to modify the request before sending it.

See https://docs.amplify.aws/lib/graphqlapi/advanced-workflows/q/platform/flutter/.

Implementation

GraphQLRequest<T> copyWith({
  String? document,
  String? apiName,
  Map<String, String>? headers,
  APIAuthorizationType? authorizationMode,
  Map<String, dynamic>? variables,
  String? decodePath,
  ModelType? modelType,
}) {
  return GraphQLRequest<T>(
    document: document ?? this.document,
    apiName: apiName ?? this.apiName,
    headers: headers ?? this.headers,
    authorizationMode: authorizationMode ?? this.authorizationMode,
    variables: variables ?? this.variables,
    decodePath: decodePath ?? this.decodePath,
    modelType: modelType ?? this.modelType,
  );
}