Skip to content

strg-at/template-graphql-yoga

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pre-commit taskfile

Project

Short project description

Table of Contents

Code-Style

ESLint

We are using eslint for linting. You can run a lint check:

task npm:run -- lint

To autofix based on defined rulset:

task npm:run -- lint:fix

pre-commit

We are using pre-commit. This is not mandatory, but you can enable the pre-commit hooks to avoid push unlinted/malformed code.

pre-commit install

Getting Started

Use npm commands in docker

Using the provided tasks, you can run npm commands within a Docker container to ensure compatibility and consistency across different environments.

Running npm commands

To run an npm command inside a Docker container, use the npm task. This task reads the Node.js version from the .nvmrc file in the repository and runs the specified npm command inside a Docker container.

Basic usage:

task npm:<npm_command> -- [<args>]

Examples:

  1. Run npm run build:

    task npm:run -- build
  2. Run npm ls:

    task npm -- ls

    or

 task npm:ls

Note:

  • You can use task command wildcards and arguments to run specific npm commands.
  • Both task npm:<command> and task npm -- <command> are supported.
  • For instance, task npm:run -- build and task npm -- run build achieve the same result.

These tasks ensure that your npm commands run within the context of the Docker container with the appropriate Node.js version specified in the .nvmrc file.

Install

task npm:install

Start Service

task npm:run -- start

Start Reloading DEV-Server

task npm:run -- dev

Running using local node

If you want to run the project using your local Node.js instead of the dockerized one, you need to pick correct Node version by running:

nvm use

Then it is possible turn on the dev server using:

npm run dev

GraphQL

Generating types from the schema

task npm:run -- build:gql-schema

This will generate the types in the file ./src/schema/resolvers-types.ts.

Note: Currently there are two graphql-modules present: books, heartbeat and scalars. However, they only serve as an example on how to structure the source code and could be deleted be later.

Configuration

Env

⚠️ Please avoid unneccessary env bloat, there's a dedicated configuration file for everything else, see below.

Name Description Default
NODE_ENV available options are (development, production, test) n/a
CONFIG_PATH PATH to the configuration file to be loaded by the client in runtime (see below) ./resources/configuration.yaml

App configuration

create the file resources/configuration.yaml and set your application configuration there.

---
app:
  port: 4000
  host: '0.0.0.0'
  environment: 'PROD'
  datasources:
    booksApi:
      url: http://some-url:3000

Preparation

All changes require a PR and review. Create a new branch and reference a Jira ticket, f.e.

git switch -c feature/INPRO-1-configure-resource

Known Issues

Future Improvements

In the future it would be nice to integrate Pothos, a plugin based GraphQL schema builder for typescript. It makes building graphql schemas in typescript easy, fast and enjoyable. An example application is available here

About

A template for GraphQL server using GraphQL Yoga and TypeScript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •