updateResolver method

Future<UpdateResolverResponse> updateResolver({
  1. required String apiId,
  2. required String fieldName,
  3. required String typeName,
  4. CachingConfig? cachingConfig,
  5. String? dataSourceName,
  6. ResolverKind? kind,
  7. PipelineConfig? pipelineConfig,
  8. String? requestMappingTemplate,
  9. String? responseMappingTemplate,
  10. SyncConfig? syncConfig,
})

Updates a Resolver object.

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

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 dataSourceName : The new data source name.

Parameter kind : The resolver type.

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

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 a 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 datasource.

Implementation

Future<UpdateResolverResponse> updateResolver({
  required String apiId,
  required String fieldName,
  required String typeName,
  CachingConfig? cachingConfig,
  String? dataSourceName,
  ResolverKind? kind,
  PipelineConfig? pipelineConfig,
  String? requestMappingTemplate,
  String? responseMappingTemplate,
  SyncConfig? syncConfig,
}) async {
  ArgumentError.checkNotNull(apiId, 'apiId');
  ArgumentError.checkNotNull(fieldName, 'fieldName');
  _s.validateStringLength(
    'fieldName',
    fieldName,
    1,
    65536,
    isRequired: true,
  );
  ArgumentError.checkNotNull(typeName, 'typeName');
  _s.validateStringLength(
    'typeName',
    typeName,
    1,
    65536,
    isRequired: true,
  );
  _s.validateStringLength(
    'dataSourceName',
    dataSourceName,
    1,
    65536,
  );
  _s.validateStringLength(
    'requestMappingTemplate',
    requestMappingTemplate,
    1,
    65536,
  );
  _s.validateStringLength(
    'responseMappingTemplate',
    responseMappingTemplate,
    1,
    65536,
  );
  final $payload = <String, dynamic>{
    if (cachingConfig != null) 'cachingConfig': cachingConfig,
    if (dataSourceName != null) 'dataSourceName': dataSourceName,
    if (kind != null) 'kind': kind.toValue(),
    if (pipelineConfig != null) 'pipelineConfig': pipelineConfig,
    if (requestMappingTemplate != null)
      'requestMappingTemplate': requestMappingTemplate,
    if (responseMappingTemplate != null)
      'responseMappingTemplate': responseMappingTemplate,
    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);
}