Skip to main content

GraphQL SuperGraph Router

This package is a generator for generating GraphQL SuperGraph using router.

Usage

danger

Note this package is currently supported on previous of GenesisX (Nx14 and Node16) please follow specific version of workspace and package

We are in the process of supporting it on latest version 3 (Nx15 and Node18)

To create GraphQL SuperGraph Router, you can follow the steps outlined below:

Pre-requisites

  • Make sure you are on correct version of Nodejs 18.x and Nx Version 16.6
    node --version
    nx --version
  • To start with, create a new GenesisX workspace in an empty directory, run below command, of if you already have the workspace ready , please skip this step.
    npx @genesisx/create-workspace
    • Provide the requested parameters
    • Provide name to your workspace like test-workspace
    • Move to the created workspace - cd test-workspace
    • Install the packages
      yarn install
  • Install GraphQL SuperGraph Router package
    yarn add @genesisx/graphql-supergraph-router
  • Now follow either of the two modes(mentioned below) to use this generator - either the Nx Console or CLI

Via Nx Console

In your Visual Studio Code, navigate to Nx Console > Generate > @genesisx/graphql-supergraph-router

And fill in the form as follows-

  • appName - Service name that will be under apps folder of your project

  • portNumber - Port Number to be changed in file called .env

  • templateName - Choose if you want to generate a router-supergraph service from the dropdown.

Click 'Run after filling the details.

Serve your graphql-router service created through Nx Console > Serve > <your_project_name>

Via Command Line

  • To integrate this package in your application, use below command:

    nx generate @genesisx/graphql-supergraph-router:templates <AppName> <PortNumber> --templateName=<TemplateName> --no-interactive
  • Replace AppName with the application name you need in string format, PortNumber should be replaced

Testing the app

You can test the newly created app using the Nx serve command

nx serve <appName>

Running build and lints

To execute the lint checks on this package, run

nx lint graphql-router

To build this package, run

nx build graphql-router

To execute the unit tests via Jest, run

nx test graphql-router

More details & Troubleshooting

Visit the troubleshooting guide for common issues or refer to the readme.md file located within the package folder <workspace-folder>/node_modules/@genesisx/graphql-supergraph-router/README.md