updateResolver method

Future<UpdateResolverResponse> updateResolver({
  1. required String apiId,
  2. required String fieldName,
  3. required String typeName,
  4. CachingConfig? cachingConfig,
  5. String? code,
  6. String? dataSourceName,
  7. ResolverKind? kind,
  8. int? maxBatchSize,
  9. ResolverLevelMetricsConfig? metricsConfig,
  10. PipelineConfig? pipelineConfig,
  11. String? requestMappingTemplate,
  12. String? responseMappingTemplate,
  13. AppSyncRuntime? runtime,
  14. SyncConfig? syncConfig,
})

Updates a Resolver object.

May throw BadRequestException. May throw ConcurrentModificationException. May throw InternalFailureException. May throw NotFoundException. May throw UnauthorizedException.

Parameter apiId : The API ID.

Parameter fieldName : The new field name.

Parameter typeName : The new type name.

Parameter cachingConfig : The caching configuration for the resolver.

Parameter code : The resolver code that contains the request and response functions. When code is used, the runtime is required. The runtime value must be APPSYNC_JS.

Parameter dataSourceName : The new data source name.

Parameter kind : The resolver type.

  • UNIT: A UNIT resolver type. A UNIT resolver is the default resolver type. You can use a UNIT resolver to run a GraphQL query against a single data source.
  • PIPELINE: A PIPELINE resolver type. You can use a PIPELINE resolver to invoke a series of Function objects in a serial manner. You can use a pipeline resolver to run a GraphQL query against multiple data sources.

Parameter maxBatchSize : The maximum batching size for a resolver.

Parameter metricsConfig : Enables or disables enhanced resolver metrics for specified resolvers. Note that metricsConfig won't be used unless the resolverLevelMetricsBehavior value is set to PER_RESOLVER_METRICS. If the resolverLevelMetricsBehavior is set to FULL_REQUEST_RESOLVER_METRICS instead, metricsConfig will be ignored. However, you can still set its value.

metricsConfig can be ENABLED or DISABLED.

Parameter pipelineConfig : The PipelineConfig.

Parameter requestMappingTemplate : The new request mapping template.

A resolver uses a request mapping template to convert a GraphQL expression into a format that a data source can understand. Mapping templates are written in Apache Velocity Template Language (VTL).

VTL request mapping templates are optional when using an Lambda data source. For all other data sources, VTL request and response mapping templates are required.

Parameter responseMappingTemplate : The new response mapping template.

Parameter syncConfig : The SyncConfig for a resolver attached to a versioned data source.

Implementation

Future<UpdateResolverResponse> updateResolver({
  required String apiId,
  required String fieldName,
  required String typeName,
  CachingConfig? cachingConfig,
  String? code,
  String? dataSourceName,
  ResolverKind? kind,
  int? maxBatchSize,
  ResolverLevelMetricsConfig? metricsConfig,
  PipelineConfig? pipelineConfig,
  String? requestMappingTemplate,
  String? responseMappingTemplate,
  AppSyncRuntime? runtime,
  SyncConfig? syncConfig,
}) async {
  _s.validateNumRange(
    'maxBatchSize',
    maxBatchSize,
    0,
    2000,
  );
  final $payload = <String, dynamic>{
    if (cachingConfig != null) 'cachingConfig': cachingConfig,
    if (code != null) 'code': code,
    if (dataSourceName != null) 'dataSourceName': dataSourceName,
    if (kind != null) 'kind': kind.value,
    if (maxBatchSize != null) 'maxBatchSize': maxBatchSize,
    if (metricsConfig != null) 'metricsConfig': metricsConfig.value,
    if (pipelineConfig != null) 'pipelineConfig': pipelineConfig,
    if (requestMappingTemplate != null)
      'requestMappingTemplate': requestMappingTemplate,
    if (responseMappingTemplate != null)
      'responseMappingTemplate': responseMappingTemplate,
    if (runtime != null) 'runtime': runtime,
    if (syncConfig != null) 'syncConfig': syncConfig,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/v1/apis/${Uri.encodeComponent(apiId)}/types/${Uri.encodeComponent(typeName)}/resolvers/${Uri.encodeComponent(fieldName)}',
    exceptionFnMap: _exceptionFns,
  );
  return UpdateResolverResponse.fromJson(response);
}