Skip to content

AndriyKalashnykov/gqlgen-gorm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang + GraphQL + GORM (schema-first)

Table Of Contents

How to Run The Project

Run the server:

make run

Navigate to https://localhost:4000 you can see GraphiQL playground and query the graphql server.

xdg-open http://localhost:4000/

createTodo

Execute createTodo mutation

make create-todo
mutation createTodo {
    createTodo(text: "todo1") {
        id
        text
        done
    }
}

Expected JSON result:

{
  "data": {
    "createTodo": {
      "id": 1,
      "text": "todo1",
      "done": false
    }
  }
}

getTodo

Execute getTodo query

make get-todo
query getTodo {
    getTodo(todoId: 1) {
        id
        text
        done
    }
}

Expected JSON result:

{
  "data": {
    "getTodo": {
      "id": 1,
      "text": "todo1",
      "done": false
    }
  }
}

getTodos

Execute getTodos query

make get-todos
query getTodos {
    getTodos {
        id
        text
        done
    }
}

Expected JSON result:

{
  "data": {
    "getTodos": [
      {
        "id": 1,
        "text": "todo1",
        "done": false
      },
      {
        "id": 2,
        "text": "todo2",
        "done": false
      },
      {
        "id": 3,
        "text": "todo3",
        "done": false
      },
      {
        "id": 4,
        "text": "todo4",
        "done": false
      },
      {
        "id": 5,
        "text": "todo5",
        "done": false
      }
    ]
  }
}

updateTodo

Execute updateTodo mutation

make update-todo
mutation updateTodo {
    updateTodo(input: {id: 1, text: "todo", done: true}) {
        id
        text
        done
    }
}

Expected JSON result:

{
  "data": {
    "updateTodo": {
      "id": 1,
      "text": "todo",
      "done": true
    }
  }
}

deleteTodo

Execute deleteTodo mutation

make delete-todo
mutation deleteTodo {
    deleteTodo(todoId: 1) {
        id
        text
        done
    }
}

Expected JSON result:

{
  "data": {
    "deleteTodo": {
      "id": 0,
      "text": "",
      "done": false
    }
  }
}

About

Golang + GraphQL + GORM

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 49.2%
  • Makefile 38.4%
  • Dockerfile 12.4%