All Projects → OscarYuen → Go Graphql Starter

OscarYuen / Go Graphql Starter

Licence: mit
This repository uses graph-gophers/graphql-go to build a starter web application

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Go Graphql Starter

Parse Server
API server module for Node/Express
Stars: ✭ 19,165 (+9294.61%)
Mutual labels:  graphql, backend
Starter
Opinionated SaaS quick-start with pre-built user account and organization system for full-stack application development in React, Node.js, GraphQL and PostgreSQL. Powered by PostGraphile, TypeScript, Apollo Client, Graphile Worker, Graphile Migrate, GraphQL Code Generator, Ant Design and Next.js
Stars: ✭ 1,082 (+430.39%)
Mutual labels:  graphql, starter
Ethql
A GraphQL interface to Ethereum 🔥
Stars: ✭ 547 (+168.14%)
Mutual labels:  graphql, backend
Ultimate Backend
Multi tenant SaaS starter kit with cqrs graphql microservice architecture, apollo federation, event source and authentication
Stars: ✭ 978 (+379.41%)
Mutual labels:  graphql, backend
Framework
Strongly-typed JavaScript object with support for validation and error handling.
Stars: ✭ 136 (-33.33%)
Mutual labels:  graphql, backend
gae-vue-webapp2-starter
A simple GAE Vue Webapp2 starter project.
Stars: ✭ 17 (-91.67%)
Mutual labels:  backend, starter
Niklick
Rails Versioned API solution template for hipsters! (Ruby, Ruby on Rails, REST API, GraphQL, Docker, RSpec, Devise, Postgress DB)
Stars: ✭ 39 (-80.88%)
Mutual labels:  graphql, starter
Bit
A tool for component-driven application development.
Stars: ✭ 14,443 (+6979.9%)
Mutual labels:  graphql, backend
Next Advanced Apollo Starter
Advanced, but minimalistic Next.js pre-configured starter with focus on DX
Stars: ✭ 131 (-35.78%)
Mutual labels:  graphql, starter
Pragma
Build GraphQL APIs In No Time
Stars: ✭ 111 (-45.59%)
Mutual labels:  graphql, backend
Graphql Microservices
Showcasing a graphql microservice setup
Stars: ✭ 68 (-66.67%)
Mutual labels:  graphql, backend
Nest User Auth
A starter build for a back end which implements managing users with MongoDB, Mongoose, NestJS, Passport-JWT, and GraphQL.
Stars: ✭ 145 (-28.92%)
Mutual labels:  graphql, backend
Graphqlws
Implementation of the GraphQL over WebSocket protocol in Go.
Stars: ✭ 139 (-31.86%)
Mutual labels:  graphql, backend
Express Graphql Typescript Boilerplate
A starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch
Stars: ✭ 163 (-20.1%)
Mutual labels:  graphql, backend
Gramps Legacy
The core data source combination engine of GrAMPS.
Stars: ✭ 198 (-2.94%)
Mutual labels:  graphql
Magellan
Real-time streaming GraphQL server for Go.
Stars: ✭ 202 (-0.98%)
Mutual labels:  graphql
Blogetc
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.
Stars: ✭ 198 (-2.94%)
Mutual labels:  backend
Wp Decoupled
Next.js app with WPGraphQL and WordPress at the backend.
Stars: ✭ 197 (-3.43%)
Mutual labels:  graphql
The Road To Graphql
📓The Road to GraphQL: Your journey to master pragmatic GraphQL in JavaScript
Stars: ✭ 203 (-0.49%)
Mutual labels:  graphql
Djangochannelsgraphqlws
Django Channels based WebSocket GraphQL server with Graphene-like subscriptions
Stars: ✭ 203 (-0.49%)
Mutual labels:  graphql

Go Graphql Starter

GitHub license

This project aims to use graph-gophers/graphql-go to build a starter web application. This project has already been used as backend application in production.

In case you need to get called from another frontend side, CORS may needed to be enabled in this application as this project mainly focuses on backend logic at this stage.

This project would be continuously under development for enhancement. Pull request is welcome.

RoadMap:

  • [x] Integrated with sqlx
  • [x] Integrated with graphql-go
  • [x] Use go-bindata to generate Go code from .graphql file
  • [x] Use psql
  • [x] Integrated with dataloader
  • [x] Add authentication & authorization
  • [ ] Add unit test cases
  • [ ] Support subscription
  • [ ] Support web-socket notification and messaging

Structure

go-graphql-starer
│   README.md
│   server.go           --- the entry file
│   Config.toml         --- the configuration file for setting server parameter
│   Dockerfile
│   Gopkg.lock          --- generated file from dependency management tool, dep
│   Gopkg.toml          --- generated file from dependency management tool, dep
│   graphiql.html       --- the html for graphiql which is used for testing query & mutation
└───context             --- application context like db configuration
└───data                --- storing the sql data patch for different version
│   └───1.0             --- storing sql data patch for version 1.0
│      └───...          --- sql files
└───handler             --- the handler used for chaining http request like authentication, logging etc.
└───loader              --- implementation of dataloader for caching and batching the graphql query
└───model               --- the folder putting struct file
└───resolver            --- implementation of graphql resolvers
└───schema              --- definition of graphql schemas
│   │   schema.go       --- used for generate go code from static graphql files inside 'type' folder
│   │   schema.graphql  --- graphql root schema
│   └───type            --- folder for storing graphql schema in *.graphql format
│       └───...         --- graphql schema files in *.graphql format
└───service             --- services for users, authorization etc.
└───util                --- utilities

Requirement:

  1. Postgres database
  2. Golang

Remark: If you want to use other databases, please feel free to change the driver in context/db.go

Usage(Without docker):

  1. Run the sql scripts under data/1.0 folder inside Postgres database console

  2. Install go-bindata

    go get -u github.com/jteeuwen/go-bindata/...
    
  3. Setup GOPATH (Optional if already set)

    For example: MacOS

    export GOPATH=/Users/${username}/go
    export PATH=$PATH:$GOPATH/bin
    
  4. Run the following command at root directory to generate Go code from .graphql file

    go-bindata -ignore=\.go -pkg=schema -o=schema/bindata.go schema/...
    

    OR

    go generate ./schema
    

    There would be bindata.go generated under schema folder

  5. Start the server (Ensure your postgres database is live and its setting in Config.toml is correct)

    go build server.go
    

Usage(With docker):

  1. Run the sql scripts under data/1.0 folder inside Postgres database console

  2. Build docker image

    docker build -t go-graphql-starter .
    
  3. Run docker image (Ensure your database setting in Config.toml is correct)

    docker run go-graphql-starter
    

Usage(With docker-compose):

  1. Create a folder /psqldata on your OS system and set it for file sharing in docker

  2. Create and starter services by docker-compose

    docker-compose up
    

Graphql Example:

Test in graphiql by the following endpoint

localhost:3000

Basically there are two graphql queries and one mutation

Query:
  1. Get a user by email
  2. Get user list by cursor pagination
Mutation:

To query a list of users, you need to be authenticated. Authentication is not required for other operations. In order to authenticate, here are the steps to follow:

  1. Create a user
mutation {
  createUser (email: "[email protected]", password: "123456") {
    id
  }
}
  1. Log in by submitting your email and password through a Basic Authorization Header.

Here's an example on how to achieve this:

   a. Download [Insomnia](https://insomnia.rest/) OR Other RESTful endpoint testing tools e.g. Postman

   b. Create a new POST request, paste `localhost:3000/login` in the URL bar and go to the Header tab

   c. Generate your basic Authorization on [blitter.se](https://www.blitter.se/utils/basic-authentication-header-generator/)

   d. In Insomnia, first column, type Authorization, second column enter the Basic you just copied `Basic dGVzdGVyQHRlc3Rlci5jb206a3Rta3Rt`

   e. Click send, you should get a jwt token back.

You can change the Authorization of request header in graphiql.html and restart the server to see the effect of authentication using token

Test:

  • Run Unit Tests
    go test
    

Reference

-graph-gophers/graphql-go

-tonyghita/graphql-go-example

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].