mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(appsync): require definition and format when creating types (#8157)
This commit is contained in:
1 parent
d05710e1d9
commit
44eb096ed5
5 files changed
+177
-12
No files matched your search
@@ -579,8 +579,11 @@ public class AppSyncService {
|
||||
public synchronized AppSyncType createType(String apiId, Map<String, Object> request) {
|
||||
assertSchemaNotBusy(apiId);
|
||||
getGraphqlApi(apiId);
|
||||
String name = (String) request.get("name");
|
||||
String definition = (String) request.get("definition");
|
||||
if (definition == null) {
|
||||
throw new AwsException("BadRequestException", "A type definition is required", 400);
|
||||
}
|
||||
String name = (String) request.get("name");
|
||||
if (name == null || name.isBlank()) {
|
||||
name = extractTypeNameFromDefinition(definition);
|
||||
}
|
||||
@@ -591,12 +594,17 @@ public class AppSyncService {
|
||||
if (typeStore.get(typeKey).isPresent()) {
|
||||
throw new AwsException("BadRequestException", "Type with name %s already exists.".formatted(name), 400);
|
||||
}
|
||||
Object formatValue = request.get("format");
|
||||
if (formatValue == null) {
|
||||
throw new AwsException("BadRequestException", "A type format is required", 400);
|
||||
}
|
||||
TypeFormat format = parseEnum(TypeFormat.class, formatValue);
|
||||
AppSyncType type = new AppSyncType();
|
||||
type.setApiId(apiId);
|
||||
type.setName(name);
|
||||
type.setDefinition((String) request.get("definition"));
|
||||
type.setDefinition(definition);
|
||||
type.setDescription((String) request.get("description"));
|
||||
type.setFormat(parseEnum(TypeFormat.class, request.getOrDefault("format", "SDL")));
|
||||
type.setFormat(format);
|
||||
|
||||
typeStore.put(typeKey, type);
|
||||
return type;
|
||||
|
||||
Reference in new issue
Block a user