createType method

Future<CreateTypeResponse> createType({
  1. required String apiId,
  2. required String definition,
  3. required TypeDefinitionFormat format,
})

Creates a Type object.

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

Parameter apiId : The API ID.

Parameter definition : The type definition, in GraphQL Schema Definition Language (SDL) format.

For more information, see the GraphQL SDL documentation.

Parameter format : The type format: SDL or JSON.

Implementation

Future<CreateTypeResponse> createType({
  required String apiId,
  required String definition,
  required TypeDefinitionFormat format,
}) async {
  ArgumentError.checkNotNull(apiId, 'apiId');
  ArgumentError.checkNotNull(definition, 'definition');
  ArgumentError.checkNotNull(format, 'format');
  final $payload = <String, dynamic>{
    'definition': definition,
    'format': format.toValue(),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/v1/apis/${Uri.encodeComponent(apiId)}/types',
    exceptionFnMap: _exceptionFns,
  );
  return CreateTypeResponse.fromJson(response);
}