Cloud Security Alliance Star Level One Badge (original) (raw)

Contributing

When your new plugin is ready, you can either:

The GraphQL Code Generator community repository contains plugins for all languages and platforms. If your plugin could be helpful for others, please consider creating a PR and maintaining it in our repo. Doing so will also promise to run your tests against the latest core changes and make sure that no breaking changes affect your plugin.

1. Requirements

To be able to clone, build and develop codegen, you’ll need to have the following installed:

GraphQL Code Generator uses the following stack to manage the source code:

  1. TypeScript - for writing the code
  2. Bob - for building, bundling, and development workflow
  3. Vitest - for running tests

2. Fork and Clone

Start by creating a Fork of the repository; this will allow you to make changes and push them quickly later: .

Then, use Git to clone your newly created fork repository.

It’s also recommended to create a new Git branch at this point, from branch.

3. Install Dependencies

GraphQL Code Generator is built as a monorepo, using Yarn Workspaces it means that all scripts and dependencies are located in the root of the project.

Now that you have a local copy of the project, start by installing the dependencies for all packages in the repo, by running the following in the root directory of the project:

4. Make sure everything works

To test the initial scripts and verify that you have a valid development environment, start by running the following scripts from the root directory:

The command above will make sure to build all common/core packages, and will make sure that all tests are passing.

5. Add your plugin

To add your plugin, start by creating a directory for it. All existing plugins are located under directory, so add it there.

Now, create a simple (or, you can copy from other plugins…)

Make sure to follow the following instructions:

  1. Make sure the package name starts with prefix.
  2. Make sure that the version is aligned with all other existing packages.
  3. Make sure that you have the following configured;
  4. Make sure your basic plugin dependencies are configured this way:

Now that your plugin is configured, you need to make sure Yarn knows about it and links it to the monorepo, so rerun the following command, in the root directory:

6. Create your plugin

To create your new plugin, create in your plugin directory, and start with the following:

You can follow the plugin tips in Write Your Plugin, Validate Configuration and Using Visitor sections.

7. Test your plugin

To test your plugin, create a test file with the following content:

Now, to make sure it works, run the following in your plugin directory:

8. Integration

You can also test the integration of your plugin with the codegen core and cli, the integration with other plugins and the output for some complex schemas and operations.

To do that, make sure everything is built by using in the root directory, then you can use it in , and run in the project root directory to run it.

If you would like to test “watch mode” in the same way, you can run .

9. Documentation

GraphQL Code Generator website has API Reference for all our plugins. Most of the documentation is generated from code, and some of it is written manually.

In order to add it to the website, do the following:

  1. Add JSDoc annotations to your config object; it can also include a default value, examples, and type:
  2. Open and add a record to the variable in that file, and point the file with the configuration annotation:

10. Feature your plugin on the Plugins Hub

To add your plugin to the Plugins hub, please follow those steps:

  1. Create a to the proper folder of , under the proper category.
    For example, the plugin has a page at .
  2. Add your plugin’s package as a dependency of the and run at the root of the repository.
  3. Update the file by adding your plugin to the array.

You must provide the relative link to your plugin typing definition. You will find examples with the existing plugins.

  1. Each plugin belongs to a category (ex: belongs to the category). Make sure that your plugin is assigned to the proper category by updating the file:

Go ahead to directory and run the website using .

Your plugin page should be available in .

Example for :

Using Visitor PatternGraphQL-CLI Deprecation