graphql-go-demo

command module
v0.0.0-...-4b43d43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2018 License: MIT Imports: 9 Imported by: 0

README

graphql-go-demo

A Graphql server demo built in Go using (graphql/graphql-go)[https://github.com/graphql-go/graphql].

The server is backed by a mysql database and exposes Post and Comment models

Installation

Clone this repository

git clone https://github.com/zianwar/go-graphql-demo

Install dependencies

go get ./...

Database configuration

  • Run the SQL query in the up.sql file.

  • Update the credentials in main.go to match your database config

    The default config ones are:

    Host: localhost
    User: root
    Password: ''
    Db Name: graphqlgodemo
    

Usage

Start the server using: go build && ./graphql-go-demo.

You can try these queries:

  • Get titles of all posts

    query {
      posts {
        title
      }
    }
    

    query1

  • Get titles of all posts and their comments

    query {
      posts {
        title
        comments {
          body
        }
      }
    }
    

    query1

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL