1.1.0 • Published 5 months ago

@diogovcs/graphql-mesh v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

NX Graphql Mesh

Nx plugin for GraphQL Mesh integration within a Nx Workspace.

Setup

Npm

npm install -D @diogovcs/graphql-mesh

Yarn

yarn add -D @diogovcs/graphql-mesh

Pnpm

pnpm add -D @diogovcs/graphql-mesh

Add to Workspace

nx generate @diogovcs/graphql-mesh:install [APP_NAME] [...OPTIONS]

This command will create a graphql mesh application with the name APP_NAME for the provided options. By default, this will create a .meshrc.yml file that is separated into multiple yaml files. This uses the yamlinc project to merge all the different configurations before build the application (this configuration can be overridden in the options). The available options allowed when generating an application are the following:

nametypedefaultdescription
--dryRunbooleanfalserun with dry mode
--singleMeshFilebooleanfalseCreates a project with a single .meshrc configuration file
--directorystringappsDirectory where the application will be created at.

Examples

Run with single mesh configuration:

nx generate @diogovcs/graphql-mesh:install my-graphql-mesh --singleMeshFile

Create app on specif folder:

nx generate @diogovcs/graphql-mesh:install my-graphql-mesh --directory=api-gateways

Build

The build executor can take optional parameters as the location of the main .meshrc.yml folder and a boolean flagging if the build should use the yamlinc to build the full .mesrc.yml configuration or not.

Here it is an example a build executor configuration:

{
  "build": {
    "executor": "@diogovcs/graphql-mesh:build",
    "options": {
      "meshYmlPath": "apps/api-gateway/config",
      "singleMeshFile": false
    }
  }
}

Options

nametypedefaultdescription
meshYmlPathstringfalsePath to the .meshrc.yml file.
singleMeshFilebooleanfalseCreates a project with a single .meshrc configuration file
envFilestring-Path to the .env file where the environment variables are located. Defaults to do not use environment files.
fileTypejsontsts Type of file.
outputPathstringPath to where the built files will be placed.
rootPathstringRoot path of the application.
tsconfigPathstringPath to where the tsconfig file is located.
typescriptSupportbooleantrueEither if typescript should be provided to transpile files. IF only using Javascript files, turn this to false, because it will decrease build time.

When using the singleMeshFile configuration with false, the compiled .meshrc.yml will be created under the .compiled folder.

Serve

The serve is intended to be used only in development as it creates a development server to listen for code changes. For Production use the start executor. Here it is an example a serve executor configuration:

{
  "serve": {
    "executor": "@diogovcs/graphql-mesh:serve",
    "options": {
      "meshYmlPath": "apps/api-gateway/config"
    }
  }
}

Options

nametypedefaultdescription
meshYmlPathstringfalsePath to the .meshrc.yml file.
envFilestring-Path to the .env file where the environment variables are located. Defaults to do not use environment files.
tsConfigPathstringGraphql Mesh default portPath to the tsconfig.json file.
mainPathstringGraphql Mesh default portPath to the main.ts file.
rootPathstringGraphql Mesh default portRoot folder of the project.

Start

Triggers the mesh start command. Should be used for production:

{
  "serve": {
    "executor": "@diogovcs/graphql-mesh:start",
    "options": {
      "meshYmlPath": "apps/api-gateway/config"
    }
  }
}

Options

nametypedefaultdescription
meshYmlPathstringfalsePath to the .meshrc.yml file.
envFilestring-Path to the .env file where the environment variables are located. Defaults to do not use environment files.
typescriptSupportbooleantrueEither if typescript should be provided to transpile files. IF only using Javascript files, turn this to false, because it will decrease build time.
1.1.0

5 months ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago