Skip to content

paulodutra/golang-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golang-graphql

A graphql server project using golang and gqlgen (https://gqlgen.com/getting-started/).

  1. For generate the graphql skeleton:
go run github.com/99designs/gqlgen init
  1. For running application:
go run cmd/server/server.go
  1. Create dabase using the sqlite3:
sqlite3 data.db
create table categories (id string, name string, description string);
  1. After the create table, access the playground using the url: http://localhost:8080/

  2. In input of web page, put the value, and after click in play button:

mutation createCategory {
  createCategory(input: {name: "tech", description: "courses"}){
    id,
    name,
    description
  }
}

mutation createCourse {
  createCourse(input: {name: "Java", description: "learning fundamentals of java", categoryId: "352f4af6-c317-4cff-bb01-c1b68799b0aa"}) {
    id
    name
  }
}

query queryCategories {
  categories {
    id
    name
    description
  }
}

query queryCategoriesWithCourses {
  categories {
    id
    name
    courses {
      id
      name
    }
  }
}

query queryCouses {
  courses {
    id
    name
  }
}

query queryCousesWithCategory {
  courses {
    id
    name
    description
    category {
      id
      name
      description
    }
  }
}

  1. create table of courses:
sqlite3 data.db
create table courses (id string, name string, description string, category_id string);
  1. For generate the of model and types:
go run github.com/99designs/gqlgen generate

About

A graphql server project using golang and gqlgen.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages