This example shows how to implement a GraphQL server with Golang based on Prisma & gqlgen.
For an advanced fork with go modules, DI, and more, see https://github.com/robojones/graphql
Clone the repository:
git clone [email protected]:steebchen/graphql.git
Ensure dependencies are available and up-to-date:
cd graphql
dep ensure -update
To run the example, you need the Prisma CLI. Please install it via Homebrew or using another method:
brew install prisma
brew tap
# or
npm i -g prisma
Start the server and the database using docker-compose:
docker-compose up -d
Deploy our schema to our database:
prisma deploy # this also runs prisma generate and gqlgen
go run .
Navigate to http://localhost:4000 in your browser to explore the API of your GraphQL server in a GraphQL Playground.
The schema that specifies the API operations of your GraphQL server is defined in ./api/schema.graphqls
. Below are a number of operations that you can send to the API using the GraphQL Playground.
Feel free to adjust any operation by adding or removing fields. The GraphQL Playground helps you with its auto-completion and query validation features.
mutation {
login(email: "[email protected]", password: "test") {
id
email
name
}
}
query {
user {
id
name
email
}
}
More coming soon.