The Go GraphQL User Store is a sample GraphQL API built using Go that provides basic user management functionality. It allows clients to query user information, create new users, and list all users. This README provides instructions for setting up, deploying, and running the service locally or on Choreo.
The following table provides a brief overview of key files and directories in this service.
Note: All paths are relative to /go/user-store
.
Filepath | Description |
---|---|
main.go |
Contains the Go code for the GraphQL User Store service. |
Dockerfile |
Docker configuration used by Choreo to build and containerize the application. |
.choreo/endpoints.yaml |
Choreo-specific configuration that defines how Choreo exposes the service to the internet. |
-
Component Creation Wizard:
- Select Service as the component type.
- Choose Go as the buildpack.
-
Configure Component Fields:
Field Description Name GraphQL User Store Service
Description A simple GraphQL service for managing users
GitHub Account wso2
GitHub Repository choreo-samples
Branch main
Buildpack Go
Go Project Directory go-graphql-service
Language Version 1.x
-
Create and Deploy:
- Click Create to set up the component. After the component is created and built, navigate to the deploy page and select Deploy to deploy the service.
- Install Go: Make sure you have Go installed on your system (Install Go).
- Install Dependencies: Install the
graphql-go
library using:go get github.com/graphql-go/graphql
- Clone choreo-samples repository.
navigate to the Go application directory and start the server.
- Navigate to the Directory:
cd go-graphql-service
- Run the Service:
go run main.go
- Access the GraphQL Endpoint: With the service running, you can access the GraphQL endpoint at:
http://localhost:8080/graphql
Here are some sample queries and mutations you can use to interact with the GraphQL User Store service.
This query returns information about a user based on their ID.
query {
user(id: "1") {
id
name
email
}
}
This query lists all users in the store.
query {
listUsers {
id
name
email
}
}
This mutation creates a new user with a name and email.
mutation {
createUser(name: "Alice", email: "alice@example.com") {
id
name
email
}
}