Skip to content

Latest commit

 

History

History

codegen-config

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

@snapwp/codegen-config

Sharable GraphQL Codegen config for the Headless WordPress ecosystem.

Warning

🐉 There be dragons! This project is in active development and considered experimental. Some features may be incomplete, unstable, or subject to change.

Installation

Run the following command:

npm install @snapwp/codegen-config --save-dev

Usage

The package provides a base configuration for @graphql-codegen/client-preset that can be extended in your project:

import baseConfig from '@snapwp/codegen-config';

export default {
	...baseConfig,
	// Add your project-specific configuration here, e.g.
	schema: 'https://my-wordpress-site.com/graphql',

	// Or use object destructuring to override specific properties
	generates: {
		// E.g. to change the output directory:
		'src/_graphql-types': baseConfig.generates[ 'src/__generated' ],

		// Or e.g. to overload client-preset options:
		'src/__generated': {
			...baseConfig.generates[ 'src/__generated' ],
			presetConfig: {
				...baseConfig.generates[ 'src/__generated' ].presetConfig,
				enumsAsTypes: false,
			},
		},
	},
};

For a real-world example, see the configuration file in SnapWP's NextJS Starter example.

Development

  • npm run build: Build the package.
  • npm run dev: Watch for changes and rebuild.
  • npm run clean: Clean build artifacts.

Contributing

This package is part of SnapWP's monorepo and is actively maintained by rtCamp. Packages are published to npm from the packages directory, and can be used standalone in the headless WordPress ecosystem or as part of SnapWP's framework.

Contributions are welcome and encouraged! To learn more about contributing to this package or SnapWP as a whole, please read the Contributing Guide.

For development guidelines, please refer to our Development Guide.

Want to expand what's possible with WordPress?

Join us at rtCamp, we specialize in providing high performance enterprise WordPress solutions.