Registry / devops / amplience-graphql-codegen-json

amplience-graphql-codegen-json

JSON →
library1.2.0jsnpmunverified

GraphQL Codegen plugin that generates Amplience JSON content type schemas from GraphQL schemas using the @amplienceContentType directive. Current stable version 1.2.0, supports Node >=18. This plugin transforms GraphQL types annotated with @amplienceContentType into JSON schema files for Amplience CMS. Unlike generic codegen plugins, it supports Amplience-specific directives like @amplienceText, @amplienceNumber, @amplienceLink, @amplienceReference, and scalars AmplienceImage/AmplienceVideo. It integrates with GraphQL Codegen presets and is typically used in CI/CD pipelines to generate Terraform-ready content type definitions.

npm install amplience-graphql-codegen-json
INSTALL
IMPORT
SIG · AMPLIENCE-GRAPHQL-
A
amplience-graphql-codegen-json
devopsjavascriptv1.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

amplience-graphql-codegen-json
import { preset } from 'amplience-graphql-codegen-json'
const preset = require('amplience-graphql-codegen-json')
ESM-only since v1.2.0, package.json has type:module

Shows codegen configuration and a sample GraphQL schema with Amplience directives, generates JSON schemas for content types.

// codegen.yml configuration overwrite: true hooks: afterAllFileWrite: - prettier --write schema: ./schema.graphql generates: terraform/amplience_content_types.tf: preset: amplience-graphql-codegen-json plugins: - amplience-graphql-codegen-json config: hostname: https://example.com/schemas // Example GraphQL schema enum Role { ADMIN USER } type Profile @amplienceContentType { displayName: String! biography: String @amplienceText(format: markdown, maxLength: 500) @amplienceLocalized avatar: AmplienceImage! age: Int @amplienceNumber(minimum: 0, maximum: 150) roles: [Role!] @amplienceList(minItems: 1, maxItems: 5) homepage: Profile @amplienceLink } type Article @amplienceContentType { title: String! body: String @amplienceText(format: richtext) author: Profile @amplienceReference publishedAt: String @amplienceDeliveryKey status: String @amplienceConst(item: "draft") }
Debug
Known issues
breakingPackage is ESM-only since v1.2.0; CommonJS require() will fail with ERR_REQUIRE_ESM.
fix
Use dynamic import() or switch to ESM. Ensure Node >=18.
affects: >=1.2.0
breakingMinimum Node.js version is now 18; older versions will fail to run.
fix
Upgrade Node.js to version 18 or higher.
affects: >=1.2.0
gotchaThe @amplienceConst directive uses 'item' for single strings and 'items' for arrays—getting these wrong will silently produce invalid schemas.
fix
Use @amplienceConst(item: 'value') for String fields; use @amplienceConst(items: ['a','b']) for [String] fields.
affects: >=1.0.0
gotchaCustom types used in fields must also have the @amplienceContentType directive, otherwise linked/referenced types will generate schemas pointing to non-existent types.
fix
Ensure every custom type referenced via @amplienceLink or @amplienceReference also carries @amplienceContentType.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'amplience-graphql-codegen-json'
Package not installed or missing from peer dependencies.
fix
npm install --save-dev amplience-graphql-codegen-json amplience-graphql-codegen-common
TypeError: (0 , preset) is not a function
Using CommonJS require() on an ESM-only package.
fix
Switch to ES modules (import instead of require) or update Node >=18.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
amplience-graphql-codegen-commonrequiredpeer dependency providing shared utilities for Amplience codegen plugins
Agent activity
14 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
amplience-graphql-codegen-json — npm install amplience-graphql-codegen-json · libregistry