appsync

AWS AppSync Integration

AWS AppSync is a managed serverless GraphQL service. In AppSync, custom GraphQL mutations are typically handled in one of two ways:

  1. APPSYNC_JS Resolvers: Written in JavaScript and executed directly within the AppSync runtime.
  2. AWS Lambda Functions: Invoked through a Lambda data source for full Node.js capabilities and database access.

The GraphQL Precognition Bridge

The standard Precognition protocol is designed for REST APIs and relies on HTTP status codes:

  • 204 No Content on validation success.
  • 422 Unprocessable Entity on validation failure.

Because GraphQL always returns 200 OK with execution results and errors embedded in the response payload, Nuxt Precognition bridges this difference so that GraphQL mutations provide the exact same client-side precognitive validation experience as REST endpoints.

Dedicated Backend Helpers

The @sot1986/appsync-precognition package provides dedicated helpers tailored for each AppSync mutation implementation:

  • JS Resolvers (@sot1986/appsync-precognition): Utilities to intercept precognitive requests and return early or format errors directly within the APPSYNC_JS resolver runtime.
  • Lambda Functions (@sot1986/appsync-precognition/middy): Middy middleware and CDK resolver response templates to handle precognitive execution and bridge structured validation errors back through AppSync to the client.

Next Steps