GithubHelp home page GithubHelp logo

brossdev / serverless-federated-gql-api Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 3.39 MB

Fully Serverless Federated GraphQL Proof of concept written in Typescript and GO.

TypeScript 51.01% Go 35.57% JavaScript 9.06% HTML 2.62% CSS 1.41% Shell 0.33%
react serverless go typescript graphql apollo-federation serverless-stack aws lambda

serverless-federated-gql-api's Introduction

Introduction

This project was built as a proof of concept to test building a Federated GraphQL API using AWS Lambda and SST Framework along with some developer tooling i wanted to experiment with. This is not designed to be production ready but does use some useful developer tooling such git hooks and a root level Typescript and Eslint config shared across the stacks.

In Development

Switch to Lambda Authoriser - After testing seperate authorisers for the subgraph and gateway, the latency was an issue as expected. The next step is to replace the HTTP and Userpool authorisers with a shared Lambda Authoriser to take advantage of the token Cacheing across all the Graph's which should improve the performance.

Technologies in this repository

Git Hooks

This project takes advantage of git hooks using Husky. Currently there are two hooks configured in the project

  • pre commit - used to run custom eslint and prettier config for consistancy across the full repository
  • pre push - used to run Go and JS tests across the repository before allowing push to remote

Infrastructure

Screenshot 2021-12-06 at 19 42 16

Core Stack

SST Stack written in typescript, responsible for deploying the core resources of the app

Cognito UserPool Post Confirmation Lambda handler ( Typescript ) DynamoDB Table GraphQL Federated Gateway Lambda ( Typescript )

SubGraph Stack

SST Stack written in Javascript, responsible for deploying each of the federated GraphQL Subgraphs

Management SubGraph

The Management Subgraph is responsible for handling the account and organisation management for the app. Creation and management of user accoounts and organisation management is handled through this subgraph

GraphQL Federated Management Subgraph Lambda ( Go )

Account SubGraph

The Account Subgraph is responsible for handling the creation and management of bank accounts and services for the app.

GraphQL Federated Account Subgraph Lambda ( Go )

Frontend

Basic React App written in typescript which is connected to the gateway lambda and userpool deployed as part of the core stack.

Prerequisities

  • go 1.17+ installed
  • node 14+ installed
  • npm 7+ installed

Running Locally

Using the SST Framework we can run the gateway and all subgraphs locally. As we don't know the subgraph routing url's ahead of time, we need to deploy the core app with placeholder subgraph urls on first deployment

From the root directory

$ npm install
$ npm run core

in a new terminal window

$ npm run subgraphs

After both subgraphs are running, take note of the AccountApiEndpoint and ManagementApiEndpoint output in the console window. Paste the management api into the routing url of the supergraph config, do the same with the account Endpoint and then restart the core service.

in the frontend repository add a .env.local file with the following proporties taken from the output of the core deployment

REACT_APP_API_URL=
REACT_APP_AWS_REGION=
REACT_APP_USER_POOL_ID=
REACT_APP_CLIENT_ID=
SKIP_PREFLIGHT_CHECK=true
$ npm run core

in a seperate terminal window

$ npm run frontend

All components of the app should now be running locally.

serverless-federated-gql-api's People

Contributors

brossdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

pablets

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.