diff --git a/compatibility-tests/sdk-test-java/pom.xml b/compatibility-tests/sdk-test-java/pom.xml
index 4867ea31e6..1a610ecbdd 100644
--- a/compatibility-tests/sdk-test-java/pom.xml
+++ b/compatibility-tests/sdk-test-java/pom.xml
@@ -252,6 +252,11 @@
software.amazon.awssdk
backup
+
+
+ software.amazon.awssdk
+ appsync
+
software.amazon.awssdk
diff --git a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
index fa1ab49d98..33d4a1d2ce 100644
--- a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
+++ b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
@@ -51,6 +51,7 @@ import software.amazon.awssdk.services.appconfig.AppConfigClient;
import software.amazon.awssdk.services.appconfigdata.AppConfigDataClient;
import software.amazon.awssdk.services.backup.BackupClient;
import software.amazon.awssdk.services.elasticloadbalancingv2.ElasticLoadBalancingV2Client;
+import software.amazon.awssdk.services.appsync.AppSyncClient;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.services.lambda.model.CreateFunctionRequest;
@@ -628,4 +629,12 @@ public final class TestFixtures {
.credentialsProvider(CREDENTIALS)
.build();
}
+
+ public static AppSyncClient appSyncClient() {
+ return AppSyncClient.builder()
+ .endpointOverride(ENDPOINT)
+ .region(REGION)
+ .credentialsProvider(CREDENTIALS)
+ .build();
+ }
}
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppSyncTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppSyncTest.java
new file mode 100644
index 0000000000..0cdbd034bb
--- /dev/null
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppSyncTest.java
@@ -0,0 +1,531 @@
+package com.floci.test;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.*;
+import software.amazon.awssdk.core.SdkBytes;
+import software.amazon.awssdk.services.appsync.AppSyncClient;
+import software.amazon.awssdk.services.appsync.model.*;
+
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.*;
+
+@DisplayName("AppSync")
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class AppSyncTest {
+
+ private static AppSyncClient client;
+ private static String apiId;
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @BeforeAll
+ static void setup() {
+ client = TestFixtures.appSyncClient();
+ }
+
+ @AfterAll
+ static void cleanup() {
+ if (apiId != null) {
+ try { client.deleteGraphqlApi(r -> r.apiId(apiId)); } catch (Exception ignored) {}
+ }
+ if (client != null) client.close();
+ }
+
+ // ── GraphQL API CRUD ────────────────────────────────────────────────
+
+ @Test
+ @Order(1)
+ void createGraphqlApi() {
+ CreateGraphqlApiResponse resp = client.createGraphqlApi(CreateGraphqlApiRequest.builder()
+ .name("sdk-test-api")
+ .authenticationType("API_KEY")
+ .tags(Map.of("env", "sdk-test"))
+ .build());
+
+ assertThat(resp.graphqlApi()).isNotNull();
+ apiId = resp.graphqlApi().apiId();
+ assertThat(apiId).isNotBlank();
+ assertThat(resp.graphqlApi().name()).isEqualTo("sdk-test-api");
+ assertThat(resp.graphqlApi().authenticationType()).isEqualTo(AuthenticationType.API_KEY);
+ assertThat(resp.graphqlApi().arn()).contains("arn:aws:appsync:");
+ }
+
+ @Test
+ @Order(2)
+ void getGraphqlApi() {
+ GetGraphqlApiResponse resp = client.getGraphqlApi(GetGraphqlApiRequest.builder()
+ .apiId(apiId)
+ .build());
+
+ assertThat(resp.graphqlApi()).isNotNull();
+ assertThat(resp.graphqlApi().apiId()).isEqualTo(apiId);
+ assertThat(resp.graphqlApi().name()).isEqualTo("sdk-test-api");
+ }
+
+ @Test
+ @Order(3)
+ void listGraphqlApis() {
+ ListGraphqlApisResponse resp = client.listGraphqlApis();
+
+ assertThat(resp.graphqlApis()).isNotEmpty();
+ assertThat(resp.graphqlApis().stream()
+ .anyMatch(a -> a.apiId().equals(apiId))).isTrue();
+ }
+
+ @Test
+ @Order(4)
+ void updateGraphqlApi() {
+ UpdateGraphqlApiResponse resp = client.updateGraphqlApi(UpdateGraphqlApiRequest.builder()
+ .apiId(apiId)
+ .name("sdk-test-api-v2")
+ .build());
+
+ assertThat(resp.graphqlApi()).isNotNull();
+ assertThat(resp.graphqlApi().name()).isEqualTo("sdk-test-api-v2");
+ }
+
+ // ── Schema ──────────────────────────────────────────────────────────
+
+ @Test
+ @Order(10)
+ void startSchemaCreation() {
+ StartSchemaCreationResponse resp = client.startSchemaCreation(StartSchemaCreationRequest.builder()
+ .apiId(apiId)
+ .definition(SdkBytes.fromUtf8String("type Query { hello: String }"))
+ .build());
+
+ assertThat(resp.status()).isNotNull();
+ }
+
+ @Test
+ @Order(11)
+ void getSchemaCreationStatus() {
+ GetSchemaCreationStatusResponse resp = client.getSchemaCreationStatus(
+ GetSchemaCreationStatusRequest.builder()
+ .apiId(apiId)
+ .build());
+
+ assertThat(resp.statusAsString()).isEqualTo("ACTIVE");
+ }
+
+ // ── API Keys ────────────────────────────────────────────────────────
+
+ private static String keyId;
+
+ @Test
+ @Order(20)
+ void createApiKey() {
+ long expiresEpoch = Instant.parse("2027-01-01T00:00:00Z").getEpochSecond();
+ CreateApiKeyResponse resp = client.createApiKey(CreateApiKeyRequest.builder()
+ .apiId(apiId)
+ .description("sdk-test-key")
+ .expires(expiresEpoch)
+ .build());
+
+ assertThat(resp.apiKey()).isNotNull();
+ keyId = resp.apiKey().id();
+ assertThat(keyId).isNotBlank();
+ assertThat(resp.apiKey().description()).isEqualTo("sdk-test-key");
+ }
+
+ @Test
+ @Order(21)
+ void listApiKeys() {
+ ListApiKeysResponse resp = client.listApiKeys(ListApiKeysRequest.builder()
+ .apiId(apiId)
+ .build());
+
+ assertThat(resp.apiKeys()).isNotEmpty();
+ }
+
+ @Test
+ @Order(22)
+ void updateApiKey() {
+ UpdateApiKeyResponse resp = client.updateApiKey(UpdateApiKeyRequest.builder()
+ .apiId(apiId)
+ .id(keyId)
+ .description("updated-sdk-key")
+ .build());
+
+ assertThat(resp.apiKey()).isNotNull();
+ assertThat(resp.apiKey().description()).isEqualTo("updated-sdk-key");
+ }
+
+ @Test
+ @Order(23)
+ void deleteApiKey() {
+ CreateApiKeyResponse created = client.createApiKey(CreateApiKeyRequest.builder()
+ .apiId(apiId)
+ .description("temp-key")
+ .build());
+
+ DeleteApiKeyResponse resp = client.deleteApiKey(DeleteApiKeyRequest.builder()
+ .apiId(apiId)
+ .id(created.apiKey().id())
+ .build());
+
+ assertThat(resp).isNotNull();
+ }
+
+ // ── Data Sources ────────────────────────────────────────────────────
+
+ @Test
+ @Order(30)
+ void createDataSource() {
+ CreateDataSourceResponse resp = client.createDataSource(CreateDataSourceRequest.builder()
+ .apiId(apiId)
+ .name("none-ds")
+ .type("NONE")
+ .build());
+
+ assertThat(resp.dataSource()).isNotNull();
+ assertThat(resp.dataSource().name()).isEqualTo("none-ds");
+ assertThat(resp.dataSource().typeAsString()).isEqualTo("NONE");
+ }
+
+ @Test
+ @Order(31)
+ void getDataSource() {
+ GetDataSourceResponse resp = client.getDataSource(GetDataSourceRequest.builder()
+ .apiId(apiId)
+ .name("none-ds")
+ .build());
+
+ assertThat(resp.dataSource()).isNotNull();
+ assertThat(resp.dataSource().name()).isEqualTo("none-ds");
+ }
+
+ @Test
+ @Order(32)
+ void listDataSources() {
+ ListDataSourcesResponse resp = client.listDataSources(ListDataSourcesRequest.builder()
+ .apiId(apiId)
+ .build());
+
+ assertThat(resp.dataSources()).isNotEmpty();
+ }
+
+ @Test
+ @Order(33)
+ void updateDataSource() {
+ UpdateDataSourceResponse resp = client.updateDataSource(UpdateDataSourceRequest.builder()
+ .apiId(apiId)
+ .name("none-ds")
+ .description("updated-ds")
+ .build());
+
+ assertThat(resp.dataSource()).isNotNull();
+ assertThat(resp.dataSource().description()).isEqualTo("updated-ds");
+ }
+
+ @Test
+ @Order(34)
+ void deleteDataSource() {
+ client.createDataSource(CreateDataSourceRequest.builder()
+ .apiId(apiId)
+ .name("temp-ds")
+ .type("NONE")
+ .build());
+
+ DeleteDataSourceResponse resp = client.deleteDataSource(DeleteDataSourceRequest.builder()
+ .apiId(apiId)
+ .name("temp-ds")
+ .build());
+
+ assertThat(resp).isNotNull();
+ }
+
+ // ── Resolvers ───────────────────────────────────────────────────────
+
+ @Test
+ @Order(40)
+ void createResolver() {
+ CreateResolverResponse resp = client.createResolver(CreateResolverRequest.builder()
+ .apiId(apiId)
+ .typeName("Query")
+ .fieldName("hello")
+ .dataSourceName("none-ds")
+ .build());
+
+ assertThat(resp.resolver()).isNotNull();
+ assertThat(resp.resolver().typeName()).isEqualTo("Query");
+ assertThat(resp.resolver().fieldName()).isEqualTo("hello");
+ }
+
+ @Test
+ @Order(41)
+ void getResolver() {
+ GetResolverResponse resp = client.getResolver(GetResolverRequest.builder()
+ .apiId(apiId)
+ .typeName("Query")
+ .fieldName("hello")
+ .build());
+
+ assertThat(resp.resolver()).isNotNull();
+ assertThat(resp.resolver().fieldName()).isEqualTo("hello");
+ }
+
+ @Test
+ @Order(42)
+ void listResolvers() {
+ ListResolversResponse resp = client.listResolvers(ListResolversRequest.builder()
+ .apiId(apiId)
+ .typeName("Query")
+ .build());
+
+ assertThat(resp.resolvers()).isNotEmpty();
+ }
+
+ @Test
+ @Order(43)
+ void updateResolver() {
+ UpdateResolverResponse resp = client.updateResolver(UpdateResolverRequest.builder()
+ .apiId(apiId)
+ .typeName("Query")
+ .fieldName("hello")
+ .dataSourceName("none-ds")
+ .responseMappingTemplate("$util.toJson({\"updated\": true})")
+ .build());
+
+ assertThat(resp.resolver()).isNotNull();
+ assertThat(resp.resolver().responseMappingTemplate()).contains("updated");
+ }
+
+ @Test
+ @Order(44)
+ void deleteResolver() {
+ client.createResolver(CreateResolverRequest.builder()
+ .apiId(apiId)
+ .typeName("Query")
+ .fieldName("tempField")
+ .dataSourceName("none-ds")
+ .build());
+
+ DeleteResolverResponse resp = client.deleteResolver(DeleteResolverRequest.builder()
+ .apiId(apiId)
+ .typeName("Query")
+ .fieldName("tempField")
+ .build());
+
+ assertThat(resp).isNotNull();
+ }
+
+ // ── Functions ───────────────────────────────────────────────────────
+
+ @Test
+ @Order(50)
+ void createFunction() {
+ CreateFunctionResponse resp = client.createFunction(CreateFunctionRequest.builder()
+ .apiId(apiId)
+ .name("sdk-function")
+ .dataSourceName("none-ds")
+ .build());
+
+ assertThat(resp.functionConfiguration()).isNotNull();
+ assertThat(resp.functionConfiguration().name()).isEqualTo("sdk-function");
+ assertThat(resp.functionConfiguration().functionId()).isNotBlank();
+ }
+
+ @Test
+ @Order(51)
+ void listFunctions() {
+ ListFunctionsResponse resp = client.listFunctions(ListFunctionsRequest.builder()
+ .apiId(apiId)
+ .build());
+
+ assertThat(resp.functions()).isNotEmpty();
+ }
+
+ @Test
+ @Order(52)
+ void updateFunction() {
+ String fnId = client.listFunctions(ListFunctionsRequest.builder()
+ .apiId(apiId)
+ .build())
+ .functions().get(0).functionId();
+
+ UpdateFunctionResponse resp = client.updateFunction(UpdateFunctionRequest.builder()
+ .apiId(apiId)
+ .functionId(fnId)
+ .name("sdk-function")
+ .dataSourceName("none-ds")
+ .description("updated-fn")
+ .build());
+
+ assertThat(resp.functionConfiguration()).isNotNull();
+ assertThat(resp.functionConfiguration().description()).isEqualTo("updated-fn");
+ }
+
+ @Test
+ @Order(53)
+ void deleteFunction() {
+ CreateFunctionResponse fnResp = client.createFunction(CreateFunctionRequest.builder()
+ .apiId(apiId)
+ .name("temp-function")
+ .dataSourceName("none-ds")
+ .build());
+
+ DeleteFunctionResponse resp = client.deleteFunction(DeleteFunctionRequest.builder()
+ .apiId(apiId)
+ .functionId(fnResp.functionConfiguration().functionId())
+ .build());
+
+ assertThat(resp).isNotNull();
+ }
+
+ // ── Tags ────────────────────────────────────────────────────────────
+
+ @Test
+ @Order(60)
+ void tagResource() {
+ GetGraphqlApiResponse api = client.getGraphqlApi(r -> r.apiId(apiId));
+ String arn = api.graphqlApi().arn();
+
+ client.tagResource(TagResourceRequest.builder()
+ .resourceArn(arn)
+ .tags(Map.of("team", "platform"))
+ .build());
+
+ ListTagsForResourceResponse resp = client.listTagsForResource(
+ ListTagsForResourceRequest.builder()
+ .resourceArn(arn)
+ .build());
+
+ assertThat(resp.tags()).containsEntry("env", "sdk-test");
+ assertThat(resp.tags()).containsEntry("team", "platform");
+ }
+
+ @Test
+ @Order(61)
+ void untagResource() {
+ GetGraphqlApiResponse api = client.getGraphqlApi(r -> r.apiId(apiId));
+ String arn = api.graphqlApi().arn();
+
+ client.untagResource(UntagResourceRequest.builder()
+ .resourceArn(arn)
+ .tagKeys("team")
+ .build());
+
+ ListTagsForResourceResponse resp = client.listTagsForResource(
+ ListTagsForResourceRequest.builder()
+ .resourceArn(arn)
+ .build());
+
+ assertThat(resp.tags()).doesNotContainKey("team");
+ assertThat(resp.tags()).containsEntry("env", "sdk-test");
+ }
+
+ // ── Types ──────────────────────────────────────────────────────────
+
+ @Test
+ @Order(70)
+ void createType() {
+ CreateTypeResponse resp = client.createType(CreateTypeRequest.builder()
+ .apiId(apiId)
+ .definition("type Item { id: ID!, name: String }")
+ .build());
+
+ assertThat(resp.type()).isNotNull();
+ assertThat(resp.type().name()).isEqualTo("Item");
+ assertThat(resp.type().definition()).contains("Item");
+ }
+
+ @Test
+ @Order(71)
+ void getType() {
+ GetTypeResponse resp = client.getType(GetTypeRequest.builder()
+ .apiId(apiId)
+ .typeName("Item")
+ .build());
+
+ assertThat(resp.type()).isNotNull();
+ assertThat(resp.type().name()).isEqualTo("Item");
+ }
+
+ @Test
+ @Order(72)
+ void listTypes() {
+ ListTypesResponse resp = client.listTypes(ListTypesRequest.builder()
+ .apiId(apiId)
+ .build());
+
+ assertThat(resp.types()).isNotEmpty();
+ }
+
+ @Test
+ @Order(73)
+ void updateType() {
+ UpdateTypeResponse resp = client.updateType(UpdateTypeRequest.builder()
+ .apiId(apiId)
+ .typeName("Item")
+ .definition("type Item { id: ID!, name: String, description: String }")
+ .build());
+
+ assertThat(resp.type()).isNotNull();
+ assertThat(resp.type().definition()).contains("description");
+ }
+
+ @Test
+ @Order(74)
+ void deleteType() {
+ client.createType(CreateTypeRequest.builder()
+ .apiId(apiId)
+ .definition("type TempType { id: ID }")
+ .build());
+
+ DeleteTypeResponse resp = client.deleteType(DeleteTypeRequest.builder()
+ .apiId(apiId)
+ .typeName("TempType")
+ .build());
+
+ assertThat(resp).isNotNull();
+ }
+
+ // ── Error Handling ─────────────────────────────────────────────────
+
+ @Test
+ @Order(80)
+ void getNonExistentApiThrowsException() {
+ assertThatThrownBy(() -> client.getGraphqlApi(GetGraphqlApiRequest.builder()
+ .apiId("nonexistent12345678901234")
+ .build()))
+ .isInstanceOf(AppSyncException.class);
+ }
+
+ @Test
+ @Order(81)
+ void getNonExistentDataSourceThrowsException() {
+ assertThatThrownBy(() -> client.getDataSource(GetDataSourceRequest.builder()
+ .apiId(apiId)
+ .name("nonexistent-ds")
+ .build()))
+ .isInstanceOf(AppSyncException.class);
+ }
+
+ @Test
+ @Order(82)
+ void getNonExistentTypeThrowsException() {
+ assertThatThrownBy(() -> client.getType(GetTypeRequest.builder()
+ .apiId(apiId)
+ .typeName("NonExistentType")
+ .build()))
+ .isInstanceOf(AppSyncException.class);
+ }
+
+ @Test
+ @Order(83)
+ void createApiKeyMissingDescriptionSucceeds() {
+ CreateApiKeyResponse resp = client.createApiKey(CreateApiKeyRequest.builder()
+ .apiId(apiId)
+ .build());
+
+ assertThat(resp.apiKey()).isNotNull();
+ assertThat(resp.apiKey().id()).isNotBlank();
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
index dd798ddc1f..1d6f2a7309 100644
--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
@@ -145,6 +145,7 @@ public interface EmulatorConfig {
NeptuneStorageConfig neptune();
BackupStorageConfig backup();
CloudFrontStorageConfig cloudfront();
+ AppSyncStorageConfig appsync();
}
interface SsmStorageConfig {
@@ -258,6 +259,13 @@ public interface EmulatorConfig {
Optional mode();
}
+ interface AppSyncStorageConfig {
+ Optional mode();
+
+ @WithDefault("5000")
+ long flushIntervalMs();
+ }
+
interface WalConfig {
@WithDefault("30000")
long compactionIntervalMs();
@@ -330,6 +338,7 @@ public interface EmulatorConfig {
BcmDataExportsServiceConfig bcmDataExports();
ConfigServiceConfig configservice();
CloudFrontServiceConfig cloudfront();
+ AppSyncServiceConfig appsync();
}
interface TransferServiceConfig {
@@ -770,6 +779,11 @@ public interface EmulatorConfig {
String domainSuffix();
}
+ interface AppSyncServiceConfig {
+ @WithDefault("true")
+ boolean enabled();
+ }
+
interface BcmDataExportsServiceConfig {
@WithDefault("true")
boolean enabled();
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
index 547f4928f6..445d4275f4 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
@@ -14,6 +14,7 @@ import io.github.hectorvent.floci.services.opensearch.OpenSearchController;
import io.github.hectorvent.floci.services.cloudfront.CloudFrontController;
import io.github.hectorvent.floci.services.route53.Route53Controller;
import io.github.hectorvent.floci.services.ses.SesController;
+import io.github.hectorvent.floci.services.appsync.AppSyncController;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
@@ -278,7 +279,12 @@ public class ResolvedServiceCatalog {
"cloudfront", storageMode(config.storage().services().cloudfront().mode(), config.storage().mode()),
5000L, AwsNamespaces.CLOUDFRONT, ServiceProtocol.REST_XML,
protocols(ServiceProtocol.REST_XML),
- Set.of(), Set.of("cloudfront"), Set.of(), Set.of(CloudFrontController.class))
+ Set.of(), Set.of("cloudfront"), Set.of(), Set.of(CloudFrontController.class)),
+ descriptor("appsync", "appsync", config.services().appsync().enabled(), true,
+ "appsync", storageMode(config.storage().services().appsync().mode(), config.storage().mode()),
+ config.storage().services().appsync().flushIntervalMs(), null, ServiceProtocol.REST_JSON,
+ protocols(ServiceProtocol.REST_JSON),
+ Set.of(), Set.of("appsync"), Set.of(), Set.of(AppSyncController.class))
));
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncController.java b/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncController.java
new file mode 100644
index 0000000000..8904c8fce2
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncController.java
@@ -0,0 +1,540 @@
+package io.github.hectorvent.floci.services.appsync;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.github.hectorvent.floci.core.common.RegionResolver;
+import io.github.hectorvent.floci.services.appsync.model.*;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.*;
+import jakarta.ws.rs.core.Context;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.jboss.logging.Logger;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+@Path("/")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class AppSyncController {
+ private static final Logger LOG = Logger.getLogger(AppSyncController.class);
+
+ private final AppSyncService service;
+ private final RegionResolver regionResolver;
+ private final ObjectMapper objectMapper;
+
+ @Inject
+ public AppSyncController(AppSyncService service,
+ RegionResolver regionResolver,
+ ObjectMapper objectMapper) {
+ this.service = service;
+ this.regionResolver = regionResolver;
+ this.objectMapper = objectMapper;
+ }
+
+ // ──────────────────────────── GraphQL API ────────────────────────────
+
+ @POST
+ @Path("/v1/apis")
+ public Response createGraphqlApi(@Context HttpHeaders headers, String body) throws IOException {
+ String region = regionResolver.resolveRegion(headers);
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ GraphqlApi api = service.createGraphqlApi(request, region);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("graphqlApi", objectMapper.valueToTree(api));
+ return Response.status(200).entity(root).build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}")
+ public Response getGraphqlApi(@PathParam("apiId") String apiId) {
+ GraphqlApi api = service.getGraphqlApi(apiId);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("graphqlApi", objectMapper.valueToTree(api));
+ return Response.ok(root).build();
+ }
+
+ @POST
+ @Path("/v1/apis/{apiId}")
+ public Response updateGraphqlApi(@Context HttpHeaders headers,
+ @PathParam("apiId") String apiId,
+ String body) throws IOException {
+ String region = regionResolver.resolveRegion(headers);
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ GraphqlApi api = service.updateGraphqlApi(apiId, request, region);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("graphqlApi", objectMapper.valueToTree(api));
+ return Response.ok(root).build();
+ }
+
+ @DELETE
+ @Path("/v1/apis/{apiId}")
+ public Response deleteGraphqlApi(@PathParam("apiId") String apiId) {
+ service.deleteGraphqlApi(apiId);
+ return Response.noContent().build();
+ }
+
+ @GET
+ @Path("/v1/apis")
+ public Response listGraphqlApis(@QueryParam("maxResults") Integer maxResults,
+ @QueryParam("nextToken") String nextToken) {
+ var page = service.listGraphqlApis(maxResults, nextToken);
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode items = root.putArray("graphqlApis");
+ page.items().forEach(items::addPOJO);
+ if (page.nextToken() != null) {
+ root.put("nextToken", page.nextToken());
+ } else {
+ root.putNull("nextToken");
+ }
+ return Response.ok(root).build();
+ }
+
+ // ──────────────────────────── Schema ────────────────────────────
+
+ @POST
+ @Path("/v1/apis/{apiId}/schemacreation")
+ public Response startSchemaCreation(@PathParam("apiId") String apiId, String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ String definition = (String) request.get("definition");
+ if (definition != null) {
+ try {
+ definition = new String(java.util.Base64.getDecoder().decode(definition), java.nio.charset.StandardCharsets.UTF_8);
+ } catch (IllegalArgumentException e) {
+ // Not base64, use as-is
+ }
+ }
+ service.startSchemaCreation(apiId, definition);
+ SchemaCreationStatus status = new SchemaCreationStatus();
+ status.setStatus(SchemaCreationStatusType.ACTIVE);
+ return Response.ok(status).build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/schemacreation")
+ public Response getSchemaCreationStatus(@PathParam("apiId") String apiId) {
+ return Response.ok(service.getSchemaCreationStatus(apiId)).build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/schema")
+ public Response getIntrospectionSchema(@PathParam("apiId") String apiId) {
+ String schema = service.getIntrospectionSchema(apiId);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.put("schema", schema);
+ return Response.ok(root).build();
+ }
+
+ // ──────────────────────────── Data Sources ────────────────────────────
+
+ @POST
+ @Path("/v1/apis/{apiId}/datasources")
+ public Response createDataSource(@PathParam("apiId") String apiId, String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ DataSource ds = service.createDataSource(apiId, request);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("dataSource", objectMapper.valueToTree(ds));
+ return Response.status(200).entity(root).build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/datasources/{name}")
+ public Response getDataSource(@PathParam("apiId") String apiId, @PathParam("name") String name) {
+ DataSource ds = service.getDataSource(apiId, name);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("dataSource", objectMapper.valueToTree(ds));
+ return Response.ok(root).build();
+ }
+
+ @POST
+ @Path("/v1/apis/{apiId}/datasources/{name}")
+ public Response updateDataSource(@PathParam("apiId") String apiId,
+ @PathParam("name") String name,
+ String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ DataSource ds = service.updateDataSource(apiId, name, request);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("dataSource", objectMapper.valueToTree(ds));
+ return Response.ok(root).build();
+ }
+
+ @DELETE
+ @Path("/v1/apis/{apiId}/datasources/{name}")
+ public Response deleteDataSource(@PathParam("apiId") String apiId,
+ @PathParam("name") String name) {
+ service.deleteDataSource(apiId, name);
+ return Response.noContent().build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/datasources")
+ public Response listDataSources(@PathParam("apiId") String apiId,
+ @QueryParam("maxResults") Integer maxResults,
+ @QueryParam("nextToken") String nextToken) {
+ var page = service.listDataSources(apiId, maxResults, nextToken);
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode items = root.putArray("dataSources");
+ page.items().forEach(items::addPOJO);
+ if (page.nextToken() != null) {
+ root.put("nextToken", page.nextToken());
+ } else {
+ root.putNull("nextToken");
+ }
+ return Response.ok(root).build();
+ }
+
+ // ──────────────────────────── Resolvers ────────────────────────────
+
+ @POST
+ @Path("/v1/apis/{apiId}/types/{typeName}/resolvers")
+ public Response createResolver(@PathParam("apiId") String apiId,
+ @PathParam("typeName") String typeName,
+ String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ request.put("typeName", typeName);
+ Resolver resolver = service.createResolver(apiId, request);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("resolver", objectMapper.valueToTree(resolver));
+ return Response.status(200).entity(root).build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/resolvers")
+ public Response listResolvers(@PathParam("apiId") String apiId,
+ @QueryParam("maxResults") Integer maxResults,
+ @QueryParam("nextToken") String nextToken) {
+ var page = service.listResolvers(apiId, maxResults, nextToken);
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode items = root.putArray("resolvers");
+ page.items().forEach(items::addPOJO);
+ if (page.nextToken() != null) {
+ root.put("nextToken", page.nextToken());
+ } else {
+ root.putNull("nextToken");
+ }
+ return Response.ok(root).build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/types/{typeName}/resolvers")
+ public Response listResolversByType(@PathParam("apiId") String apiId,
+ @PathParam("typeName") String typeName,
+ @QueryParam("maxResults") Integer maxResults,
+ @QueryParam("nextToken") String nextToken) {
+ var page = service.listResolversByType(apiId, typeName, maxResults, nextToken);
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode items = root.putArray("resolvers");
+ page.items().forEach(items::addPOJO);
+ if (page.nextToken() != null) {
+ root.put("nextToken", page.nextToken());
+ } else {
+ root.putNull("nextToken");
+ }
+ return Response.ok(root).build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/types/{typeName}/resolvers/{fieldName}")
+ public Response getResolver(@PathParam("apiId") String apiId,
+ @PathParam("typeName") String typeName,
+ @PathParam("fieldName") String fieldName) {
+ Resolver resolver = service.getResolver(apiId, typeName, fieldName);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("resolver", objectMapper.valueToTree(resolver));
+ return Response.ok(root).build();
+ }
+
+ @POST
+ @Path("/v1/apis/{apiId}/types/{typeName}/resolvers/{fieldName}")
+ public Response updateResolver(@PathParam("apiId") String apiId,
+ @PathParam("typeName") String typeName,
+ @PathParam("fieldName") String fieldName,
+ String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ Resolver resolver = service.updateResolver(apiId, typeName, fieldName, request);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("resolver", objectMapper.valueToTree(resolver));
+ return Response.ok(root).build();
+ }
+
+ @DELETE
+ @Path("/v1/apis/{apiId}/types/{typeName}/resolvers/{fieldName}")
+ public Response deleteResolver(@PathParam("apiId") String apiId,
+ @PathParam("typeName") String typeName,
+ @PathParam("fieldName") String fieldName) {
+ service.deleteResolver(apiId, typeName, fieldName);
+ return Response.noContent().build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/functions/{functionId}/resolvers")
+ public Response listResolversByFunction(@PathParam("apiId") String apiId,
+ @PathParam("functionId") String functionId,
+ @QueryParam("maxResults") Integer maxResults,
+ @QueryParam("nextToken") String nextToken) {
+ var page = service.listResolversByFunction(apiId, functionId, maxResults, nextToken);
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode items = root.putArray("resolvers");
+ page.items().forEach(items::addPOJO);
+ if (page.nextToken() != null) {
+ root.put("nextToken", page.nextToken());
+ } else {
+ root.putNull("nextToken");
+ }
+ return Response.ok(root).build();
+ }
+
+ // ──────────────────────────── Functions ────────────────────────────
+
+ @POST
+ @Path("/v1/apis/{apiId}/functions")
+ public Response createFunction(@Context HttpHeaders headers,
+ @PathParam("apiId") String apiId, String body) throws IOException {
+ String region = regionResolver.resolveRegion(headers);
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ FunctionConfiguration fn = service.createFunction(apiId, request, region);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("functionConfiguration", objectMapper.valueToTree(fn));
+ return Response.status(200).entity(root).build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/functions/{functionId}")
+ public Response getFunction(@PathParam("apiId") String apiId, @PathParam("functionId") String functionId) {
+ FunctionConfiguration fn = service.getFunction(apiId, functionId);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("functionConfiguration", objectMapper.valueToTree(fn));
+ return Response.ok(root).build();
+ }
+
+ @POST
+ @Path("/v1/apis/{apiId}/functions/{functionId}")
+ public Response updateFunction(@PathParam("apiId") String apiId,
+ @PathParam("functionId") String functionId,
+ String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ FunctionConfiguration fn = service.updateFunction(apiId, functionId, request);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("functionConfiguration", objectMapper.valueToTree(fn));
+ return Response.ok(root).build();
+ }
+
+ @DELETE
+ @Path("/v1/apis/{apiId}/functions/{functionId}")
+ public Response deleteFunction(@PathParam("apiId") String apiId,
+ @PathParam("functionId") String functionId) {
+ service.deleteFunction(apiId, functionId);
+ return Response.noContent().build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/functions")
+ public Response listFunctions(@PathParam("apiId") String apiId,
+ @QueryParam("maxResults") Integer maxResults,
+ @QueryParam("nextToken") String nextToken) {
+ var page = service.listFunctions(apiId, maxResults, nextToken);
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode items = root.putArray("functions");
+ page.items().forEach(items::addPOJO);
+ if (page.nextToken() != null) {
+ root.put("nextToken", page.nextToken());
+ } else {
+ root.putNull("nextToken");
+ }
+ return Response.ok(root).build();
+ }
+
+ // ──────────────────────────── Types ────────────────────────────
+
+ @POST
+ @Path("/v1/apis/{apiId}/types")
+ public Response createType(@PathParam("apiId") String apiId, String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ AppSyncType type = service.createType(apiId, request);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("type", objectMapper.valueToTree(type));
+ return Response.status(200).entity(root).build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/types/{typeName}")
+ public Response getType(@PathParam("apiId") String apiId, @PathParam("typeName") String typeName) {
+ AppSyncType type = service.getType(apiId, typeName);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("type", objectMapper.valueToTree(type));
+ return Response.ok(root).build();
+ }
+
+ @POST
+ @Path("/v1/apis/{apiId}/types/{typeName}")
+ public Response updateType(@PathParam("apiId") String apiId,
+ @PathParam("typeName") String typeName,
+ String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ AppSyncType type = service.updateType(apiId, typeName, request);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("type", objectMapper.valueToTree(type));
+ return Response.ok(root).build();
+ }
+
+ @DELETE
+ @Path("/v1/apis/{apiId}/types/{typeName}")
+ public Response deleteType(@PathParam("apiId") String apiId,
+ @PathParam("typeName") String typeName) {
+ service.deleteType(apiId, typeName);
+ return Response.noContent().build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/types")
+ public Response listTypes(@PathParam("apiId") String apiId,
+ @QueryParam("maxResults") Integer maxResults,
+ @QueryParam("nextToken") String nextToken) {
+ var page = service.listTypes(apiId, maxResults, nextToken);
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode items = root.putArray("types");
+ page.items().forEach(items::addPOJO);
+ if (page.nextToken() != null) {
+ root.put("nextToken", page.nextToken());
+ } else {
+ root.putNull("nextToken");
+ }
+ return Response.ok(root).build();
+ }
+
+ // ──────────────────────────── API Keys ────────────────────────────
+
+ @POST
+ @Path("/v1/apis/{apiId}/apikeys")
+ public Response createApiKey(@PathParam("apiId") String apiId, String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ ApiKey key = service.createApiKey(apiId, request);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("apiKey", objectMapper.valueToTree(key));
+ return Response.status(200).entity(root).build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/apikeys")
+ public Response listApiKeys(@PathParam("apiId") String apiId,
+ @QueryParam("maxResults") Integer maxResults,
+ @QueryParam("nextToken") String nextToken) {
+ var page = service.listApiKeys(apiId, maxResults, nextToken);
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode items = root.putArray("apiKeys");
+ page.items().forEach(items::addPOJO);
+ if (page.nextToken() != null) {
+ root.put("nextToken", page.nextToken());
+ } else {
+ root.putNull("nextToken");
+ }
+ return Response.ok(root).build();
+ }
+
+ @GET
+ @Path("/v1/apis/{apiId}/apikeys/{keyId}")
+ public Response getApiKey(@PathParam("apiId") String apiId, @PathParam("keyId") String keyId) {
+ ApiKey key = service.getApiKey(apiId, keyId);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("apiKey", objectMapper.valueToTree(key));
+ return Response.ok(root).build();
+ }
+
+ @POST
+ @Path("/v1/apis/{apiId}/apikeys/{keyId}")
+ public Response updateApiKey(@PathParam("apiId") String apiId,
+ @PathParam("keyId") String keyId,
+ String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ ApiKey key = service.updateApiKey(apiId, keyId, request);
+ ObjectNode root = objectMapper.createObjectNode();
+ root.set("apiKey", objectMapper.valueToTree(key));
+ return Response.ok(root).build();
+ }
+
+ @DELETE
+ @Path("/v1/apis/{apiId}/apikeys/{keyId}")
+ public Response deleteApiKey(@PathParam("apiId") String apiId, @PathParam("keyId") String keyId) {
+ service.deleteApiKey(apiId, keyId);
+ return Response.noContent().build();
+ }
+
+ // ──────────────────────────── Tags ────────────────────────────
+
+ @POST
+ @Path("/v1/tags/{resourceArn: .+}")
+ public Response tagResource(@PathParam("resourceArn") String resourceArn, String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ @SuppressWarnings("unchecked")
+ Map tags = (Map) request.get("tags");
+ service.tagResource(resourceArn, tags);
+ return Response.noContent().build();
+ }
+
+ @DELETE
+ @Path("/v1/tags/{resourceArn: .+}")
+ public Response untagResource(@PathParam("resourceArn") String resourceArn,
+ @QueryParam("tagKeys") List tagKeys) {
+ service.untagResource(resourceArn, tagKeys);
+ return Response.noContent().build();
+ }
+
+ @GET
+ @Path("/v1/tags/{resourceArn: .+}")
+ public Response listTagsForResource(@PathParam("resourceArn") String resourceArn) {
+ Map tags = service.getTags(resourceArn);
+ ObjectNode root = objectMapper.createObjectNode();
+ ObjectNode tagsNode = root.putObject("tags");
+ tags.forEach(tagsNode::put);
+ return Response.ok(root).build();
+ }
+
+ // ──────────────────────────── Environment Variables ────────────────────────────
+
+ @GET
+ @Path("/v1/apis/{apiId}/environmentvariables")
+ public Response getEnvironmentVariables(@PathParam("apiId") String apiId) {
+ Map envVars = service.getEnvironmentVariables(apiId);
+ ObjectNode root = objectMapper.createObjectNode();
+ ObjectNode envNode = root.putObject("environmentVariables");
+ envVars.forEach(envNode::put);
+ return Response.ok(root).build();
+ }
+
+ @PUT
+ @Path("/v1/apis/{apiId}/environmentvariables")
+ public Response putEnvironmentVariables(@PathParam("apiId") String apiId,
+ String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map request = objectMapper.readValue(body, Map.class);
+ @SuppressWarnings("unchecked")
+ Map envVars = (Map) request.get("environmentVariables");
+ if (envVars == null) {
+ envVars = Map.of();
+ }
+ Map result = service.putEnvironmentVariables(apiId, envVars);
+ ObjectNode root = objectMapper.createObjectNode();
+ ObjectNode envNode = root.putObject("environmentVariables");
+ result.forEach(envNode::put);
+ return Response.ok(root).build();
+ }
+
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncService.java b/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncService.java
new file mode 100644
index 0000000000..7f27bf3d89
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appsync/AppSyncService.java
@@ -0,0 +1,631 @@
+package io.github.hectorvent.floci.services.appsync;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import io.github.hectorvent.floci.config.EmulatorConfig;
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.RegionResolver;
+import io.github.hectorvent.floci.core.storage.StorageBackend;
+import io.github.hectorvent.floci.core.storage.StorageFactory;
+import io.github.hectorvent.floci.services.appsync.model.*;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import org.jboss.logging.Logger;
+
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.Base64;
+
+@ApplicationScoped
+public class AppSyncService {
+ private static final Logger LOG = Logger.getLogger(AppSyncService.class);
+
+ private final StorageBackend apiStore;
+ private final StorageBackend schemaStore; // apiId -> schema SDL
+ private final StorageBackend schemaStatusStore;
+ private final StorageBackend dataSourceStore;
+ private final StorageBackend resolverStore;
+ private final StorageBackend functionStore;
+ private final StorageBackend apiKeyStore;
+ private final StorageBackend typeStore;
+ private final RegionResolver regionResolver;
+
+ @Inject
+ public AppSyncService(StorageFactory storageFactory, EmulatorConfig config, RegionResolver regionResolver) {
+ this.apiStore = storageFactory.create("appsync", "appsync-apis.json", new TypeReference<>() {});
+ this.schemaStore = storageFactory.create("appsync", "appsync-schemas.json", new TypeReference<>() {});
+ this.schemaStatusStore = storageFactory.create("appsync", "appsync-schema-status.json", new TypeReference<>() {});
+ this.dataSourceStore = storageFactory.create("appsync", "appsync-datasources.json", new TypeReference<>() {});
+ this.resolverStore = storageFactory.create("appsync", "appsync-resolvers.json", new TypeReference<>() {});
+ this.functionStore = storageFactory.create("appsync", "appsync-functions.json", new TypeReference<>() {});
+ this.apiKeyStore = storageFactory.create("appsync", "appsync-apikeys.json", new TypeReference<>() {});
+ this.typeStore = storageFactory.create("appsync", "appsync-types.json", new TypeReference<>() {});
+ this.regionResolver = regionResolver;
+ }
+
+ // ──────────────────────────── GraphQL API ────────────────────────────
+
+ public GraphqlApi createGraphqlApi(Map request, String region) {
+ String name = (String) request.get("name");
+ if (name == null || name.isBlank()) {
+ throw new AwsException("BadRequestException", "A GraphQL API name is required", 400);
+ }
+ String apiId = generateApiId();
+ GraphqlApi api = new GraphqlApi();
+ api.setApiId(apiId);
+ api.setName(name);
+ api.setAuthenticationType(parseEnum(AuthenticationType.class, request.get("authenticationType")));
+ Object xrayValue = request.get("xrayEnabled");
+ if (xrayValue instanceof Boolean b) {
+ api.setXrayEnabled(b);
+ } else if (xrayValue instanceof String s) {
+ api.setXrayEnabled(Boolean.parseBoolean(s));
+ } else {
+ api.setXrayEnabled(false);
+ }
+ api.setLogConfig((Map) request.get("logConfig"));
+
+ Object additionalObj = request.get("additionalAuthenticationProviders");
+ if (additionalObj instanceof List> additionalList) {
+ List