GraphQL SuperGraph Gateway
This package is a generator for generating GraphQL Federation SuperGraph and services using Federation and Gateway.
Usage
To create GraphQL SuperGraph Gateway, 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
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 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 Gateway package
yarn add @genesisx/graphql-supergraph-gateway
- 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-gateway
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 chose if you want to generate a federation-supergraph service from the dropdown.
Click on Run after filling the details.
Serve your graphql-supergraph service created through Nx console > Serve > <your_project_name>
Via Command Line
If Nx is not already installed, then install it using
npm install -g nx
Use below command to create a template-
nx generate @genesisx/graphql-supergraph-gateway:templates <AppName> <PortNumber> --templateName=<TemplateName> --no-interactive
Replace AppName with the application name you need in string format, PortNumber should be replaced
Or just run the following and provide the required parameters-
nx generate @genesisx/graphql-supergraph-gateway:templates
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 <appName>
To build this package, run
nx build <appName>
To execute the unit tests via Jest, run-
nx test <appName>
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-gateway/README.md