A Golang API that utilizes GraphQL for managing courses and categories. This project provides a simple interface for querying and mutating data related to courses and categories using GraphQL.
- Docker
- Docker Compose
- Go
-
Clone the repository:
git clone https://github.com/ogabrielinacio/go-graphql.git cd go-graphql
-
Start the database:
You can start the PostgreSQL database using Docker Compose. Make sure you have the required environment variables set in the
envs
file.docker-compose --env-file envs up
-
Create the necessary tables:
Once the PostgreSQL container is up and running, connect to the database and create the following tables:
CREATE TABLE Categories ( Id VARCHAR(255), Name VARCHAR(255), Description TEXT ); CREATE TABLE Course ( Id VARCHAR(255), Name VARCHAR(255), Description TEXT, CategoryId VARCHAR(255) );
-
Set environment variables:
Ensure you have the correct environment variables set in the
envs
by running the following command:export $(grep -v '^#' envs | xargs)
-
Run the application:
Finally, start the Golang application by running the following command:
go run cmd/server/server.go
Once the application is running, you can interact with the GraphQL API by sending queries and mutations to manage courses
and categories
.
Now you can execute the queries and mutations in the queries.graphql
file.