- Sangria
- http4s
- MongoDB
- Circe
Add an own db.conf
file in resources
with the following properties:
db {
connectionString: "<your mongo connection string>"
name: "<your db name>"
user: "<user>"
password: "<password>"
}
- start the server (runs on localhost:8080)
- the server is implemented to work with
GET
(url parameters) as well asPOST
(parameters in the body) requests against the/graphql
endpoint - do some mutations & queries (here with httpie against the
POST
endpoint)
echo '{
"query": "mutation Foo($draft: ProductInput!) { createProduct(productDraft: $draft) { id name description } }",
"variables": {
"draft": {
"name": "Tenet - BluRay",
"description": "sator arepo tenet opera rotas"
}
}
}' | http -f POST :8080/graphql
echo '{ "query" : "query { products { name id } }" }' | http -f POST :8080/graphql
echo '{
"query": "mutation Foo($id: String!, $draft: ProductInput!) { updateProduct(id: $id, productDraft: $draft) { id name description } }",
"variables": {
"id": "<put in the ID of the product you wanna update>",
"draft": {
"name": "Tenet - BluRay",
"description": "The story of inverted entropy."
}
}
}' | http -f POST :8080/graphql
echo '{
"query": "mutation Foo($id: String!) { deleteProduct(id: $id) }",
"variables": { "id": "<put in the ID of the product you wanna delete>" }
}' | http -f POST :8080/graphql