graphql-golang
graphql-golang copied to clipboard
A tutorial for creating GrahpQL APIs in go
trafficstars
title: Introduction To GraphQL Server With Golang published: false description: Introduction to GraphQL Server with Golang and Gqlgen. tags: graphql, go, api, gqlgen
Table Of Contents
- Table Of Contents
- How to Run The Project
- Motivation
- What is a GraphQL server?
- Schema-Driven Development
- Getting started
- Project Setup
- Defining Our Schema
- Queries
- What Is A Query
- Simple Query
- Mutations
- What Is A Mutation
- A Simple Mutation
- Database
- Setup MySQL
- Models and migrations
- Create and Retrieve Links
- CreateLinks
- Links Query
- Authentication
- JWT
- Setup
- Generating and Parsing JWT Tokens
- User Signup and Login Functionality
- Authentication Middleware
- Continue Implementing schema
- CreateUser
- Login
- RefreshToken
- Completing Our App
- Summary
- Further Steps
How to Run The Project
First start mysql server with docker:
docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=dbpass -e MYSQL_DATABASE=hackernews -d mysql:latest
Then create a Table names hackernews for our app:
docker exec -it mysql bash
mysql -u root -p
CREATE DATABASE hackernews;
finally run the server:
go run server/server.go
Now navigate to https://localhost:8080 you can see graphiql playground and query the graphql server.
Tutorial
to see the latest version of tutorial visit https://www.howtographql.com/graphql-go/0-introduction/