GraphQL Application Initial Setup
Learn how to set up the GraphQL application.
Introduction
This application is created with the Go programming language and with some additional libraries. The libraries that are used in this project are:
- gqlgen: Used for creating a server with its handler.
- UUID: Used for creating an ID for data or records inside the storage.
Initialize the project
You may use the following commands to initialize the project if you have to set it up on a local machine. However, it has already been set up for you on the Educative platform.
go mod init domain_name/username/project_name
This is an example of initializing the project command.
go mod init github.com/nadirbasalamah/go-gql-blogs
After the project is initialized, install the following libraries.
go get github.com/99designs/gqlgen@v0.17.10
go get github.com/google/uuid
Initialize the application
Initialize the GraphQL application with this command.
go run github.com/99designs/gqlgen init
Define the schema
The schema.graphqls
contains the schema definition for the GraphQL application that contains the default schema for the application. We define the schema for the blog application in that file.
Get hands-on with 1400+ tech skills courses.