All Projects → tomyitav → graphql-server-typed

tomyitav / graphql-server-typed

Licence: MIT license
Using typescript and gql-code-gen for easy graphql setup

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to graphql-server-typed

Graphql Modules
Enterprise Grade Tooling For Your GraphQL Server
Stars: ✭ 962 (+2906.25%)
Mutual labels:  dependency-injection, apollo-server
typescript-graphql-postgres-boilerplate
Simple boilerplate integrated typescript, graphql, postgres and apollo server
Stars: ✭ 18 (-43.75%)
Mutual labels:  apollo-server
inversify-koa-utils
inversify-koa-utils is a module based on inversify-express-utils. This module has utilities for koa 2 applications development using decorators and IoC Dependency Injection (with inversify)
Stars: ✭ 27 (-15.62%)
Mutual labels:  dependency-injection
di speed
Speed comparison of Dependency Injection Container
Stars: ✭ 18 (-43.75%)
Mutual labels:  dependency-injection
varie
A Typescript Framework For VueJS
Stars: ✭ 23 (-28.12%)
Mutual labels:  dependency-injection
NetteAdapterForSymfonyBundles
[DEPRECATED due to only 20 downloads per 2 years] Read an article about this idea
Stars: ✭ 15 (-53.12%)
Mutual labels:  dependency-injection
di
Simple and yet powerful Dependency Injection for Go
Stars: ✭ 188 (+487.5%)
Mutual labels:  dependency-injection
rodi
Implementation of dependency injection for Python 3
Stars: ✭ 42 (+31.25%)
Mutual labels:  dependency-injection
AzureFunctions.Extensions
This provides some useful extensions for Azure Functions.
Stars: ✭ 81 (+153.13%)
Mutual labels:  dependency-injection
les-chat
Real-time messenger with private, public & group chat. Made using PERN + GraphQL stack.
Stars: ✭ 48 (+50%)
Mutual labels:  apollo-server
serverless-apollo-datasource-redis
Serverless Apollo Server 2 with cached Datasource in Redis
Stars: ✭ 26 (-18.75%)
Mutual labels:  apollo-server
react-obsidian
Dependency injection framework for React and React Native applications
Stars: ✭ 17 (-46.87%)
Mutual labels:  dependency-injection
linker
Dependency Injection and Inversion of Control package
Stars: ✭ 33 (+3.13%)
Mutual labels:  dependency-injection
aws-nestjs-starter
Serverless, AWS, NestJS, GraphQL and DynamoDB starter
Stars: ✭ 200 (+525%)
Mutual labels:  apollo-server
sirius-kernel
Provides common core classes and the dependency injection microkernel powering all SIRIUS applications
Stars: ✭ 30 (-6.25%)
Mutual labels:  dependency-injection
boilerplate-nexus-prisma-apollo-graphql-express
Boilerplate project for a graphql server using nexus-prisma and apollo-server-express
Stars: ✭ 31 (-3.12%)
Mutual labels:  apollo-server
BESTV
Android TV App powered by TMDb. It is a easy way to find the best TV content, the top movies, series... all of that in your TV.
Stars: ✭ 49 (+53.13%)
Mutual labels:  dependency-injection
inject
A simple Kotlin multi-platform abstraction around the javax.inject annotations.
Stars: ✭ 42 (+31.25%)
Mutual labels:  dependency-injection
func-dependency-injection-go
Dependency injection example using higher order functions
Stars: ✭ 26 (-18.75%)
Mutual labels:  dependency-injection
redi
💉 A dependency injection library for TypeScript & JavaScript, along with a binding for React.
Stars: ✭ 29 (-9.37%)
Mutual labels:  dependency-injection

graphql-server-typed

MIT licensed code style: prettier renovate-app badge

Boilerplate project for create-graphql-app cli.

Create a fully configured, production ready graphql server, using

  • typescript
  • graphql-code-generator
  • graphql-subscriptions
  • merge-graphql-schemas
  • Dependency injection with injection-js

This project demonstrates how to generate typescript types from graphql schema, using Graphql code generetor library.

Installation

Clone the repository and run npm install

git clone https://github.com/tomyitav/graphql-server-typed.git
npm install

Build and start server instance

Build command

Running the command

npm run build

Or on windows machine, run

npm run build:win

will generate typescript types, and transpile code to dist folder

How to start server instance after building

npm start

Run server directly with ts-node

npm start:dev

Watch for code changes

npm run start:watch

This will monitor your changes and will automatically restart the server.

The server will run on port 8080. You can change this by editing the config file.

Code Formatting

We use Prettier and Tslint to format and enforce standards on our code.
Both will run on the project automatically before each commit.

Prettier rewrites code according to the .prettierrc.json configuration file.
If you want to activate prettier manually (on all .ts files inside src folder) without committing, run:

npm run prettier

Tslint will check rules found in the tslint.json configuration file.
If you want to check tslint manually (on all .ts files inside src folder) without committing, run:

npm run tslint

Type generation using gql codegen

npm run generate

This will automatically generate types in types.d.ts file! generate command is executed in every build

Project structure

We use the function makeExecutableSchema() from graphql-tools to to combine our types and resolvers. Instead of passing one large string for our schema, we split our types and resolvers to multiple files, located in graphql directory in types and resolvers directories. This way, we avoid schema complexity by using merge-graphql-schemas:

  import * as path from "path";
  import {makeExecutableSchema} from "graphql-tools";
  import {fileLoader, mergeTypes, mergeResolvers} from "merge-graphql-schemas";
  import {GraphQLSchema} from "graphql";

  const typesArray = fileLoader(path.join(__dirname, '../types'), { recursive: true });
  const resolversArray = fileLoader(path.join(__dirname, '../resolvers'));
  const allTypes = mergeTypes(typesArray);
  const allResolvers = mergeResolvers(resolversArray);
  let schema: GraphQLSchema;
  schema= makeExecutableSchema({
      typeDefs: allTypes,
      resolvers: allResolvers
  });

  export default schema;

So as your project grows - you can extend the schema by adding new type in types directory, and adding matching resolver file in resolvers directory. The schema is updated automatically.

Deploy server to production 🚀

First, make sure you have now-cli installed. Then, execute the following command:

npm run deploy

That's it! The server will be deployed on now

Run server as AWS lambda

See the following project for setting up aws lambda integration

Connect to the server from client app

See the following example on how to connect to the server using apollo-angular.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].