This repository contains a GraphQL server for managing reminder listings. The server is built using gqlgen, a popular GraphQL library for Go. The application allows users to create, update, and delete reminder listings.
The main entry point of the GraphQL server. It initializes the server, connects to the database, and sets up the GraphQL schema. The server is configured to read environment variables from a .env
file, and it retrieves the database connection URL (DB_URL
) from these variables.
This file is used for managing external tools with the //go:build tools
build tag. In this case, it includes the gqlgen
tool.
The database package contains the logic for connecting to the PostgreSQL database. It reads the database connection URL from the environment variables, establishes a connection, and checks the database status.
This file contains the GraphQL resolver implementations. Resolvers handle the actual execution of GraphQL queries and mutations. The implemented resolvers include:
CreateReminderListing
: Creates a new reminder listing.UpdateReminderListing
: Updates an existing reminder listing.DeleteReminderListing
: Deletes a reminder listing.Reminders
: Retrieves all reminder listings.Reminder
: Retrieves a specific reminder listing by ID.
The resolvers use the database connection established in the database.go
file.
-
Clone the Repository:
git clone <repository-url> cd <repository-directory>
-
Set Up the Environment: Create a
.env
file with the following content:DB_URL=<your-database-url>
-
Run the Server:
go run server.go
-
Explore GraphQL API: Open your browser and go to
http://localhost:8080/
to access the GraphQL Playground. Here, you can interact with the GraphQL API and test different queries and mutations.
Feel free to explore and modify the code based on your requirements. This repository serves as a starting point for building GraphQL APIs in Go using gqlgen
.