This is a recreational programming project to implement a NestJS GraphQL API adapter for the National Parks Service API.
The source tree was generated with:
alias nest='npx @nestjs/[email protected]'
nest new nps_graphql
GraphQL dependencies were installed with:
npm i @nestjs/graphql @nestjs/apollo @apollo/server graphql
See Nest GraphQL quick start).
A new module, service, and resolver was added for NPS specific code:
npx nest g module nps
npx nest g service nps
npx nest g resolver nps
I found swagger.json by inspecting the browser requests made on the API doc page.
I then converted the Swagger 2 file to OpenAPI 3:
npx swagger2openapi swagger.json > nps_openapi.json
I then generated NestJS GraphQL models in <./src/nps/nps.types.ts> using Github Copilot within VSCode:
"Using #file:nps_openapi.json generate all models in #file:nps.types.ts.
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
You can then visit the GraphQL Playground in your browser:
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
$ npm install -g mau
$ mau deploy
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.