A GraphQL transform directive (@versioned) for AWS AppSync that adds object versioning and conflict resolution to @model types. Part of the Amplify GraphQL Transformer ecosystem, this package enables optimistic locking and conflict detection for GraphQL mutations. Version 5.2.80 targets the Amplify Gen 1 GraphQL Transformer v2, compatible with @aws-amplify/graphql-transformer-core. It is deprecated in favor of Amplify GraphQL Transformer v3+ built-in conflict resolution. Key differentiators: integrates directly with AppSync resolvers for DynamoDB, automatic version increment on updates, conditional writes for safe concurrent edits. Release cadence is tied to Amplify CLI releases, typically bi-weekly. Not intended for standalone use outside Amplify.
npm install graphql-versioned-transformerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to instantiate VersionedTransformer, add it to GraphQLTransform, and transform a schema with @versioned directive on a @model type.
Migrate to Amplify GraphQL Transformer v3 which supports versioning and conflict resolution without a separate directive. See Amplify documentation for migration guide.
Use constructor: new VersionedTransformer() instead of factory. Check @aws-amplify/graphql-transformer-core peer dependency version.
Ensure every @model with @versioned includes a version: Int! field, otherwise the transformer will throw.
Always include a version field in your GraphQL schema for models using @versioned.
Install the peer dependencies: npm i @aws-amplify/graphql-transformer-core graphql graphql-mapping-template graphql-transformer-common
Use npm i graphql-versioned-transformer and ensure your project is ESM (use import instead of require). If using CJS, consider upgrading to ESM or use dynamic import.
Correct code: const transformer = new VersionedTransformer(); transform.add(transformer); Or pass in transformers array.
Ensure VersionedTransformer is included in the transformers array passed to GraphQLTransform constructor.
Add 'version: Int!' to the model type.