Edit the build.gradle and add:
implementation 'com.google.cloud:spring-cloud-gcp-starter-data-firestore'$env:JAVA_HOME="c:\Program Files\Java\jdk-24\"
.\gradlew.bat bootrun
export GOOGLE_APPLICATION_CREDENTIALS="/usr/local/google/home/pwujczyk/github/Home.Configuration/PTProjectsWeb.Firebase.ServiceAccount.json"
chmod +x ./gradlew
./gradlew bootRun
If env variable was not set earlier
./gradlew --stop
export GOOGLE_APPLICATION_CREDENTIALS="/usr/local/google/home/pwujczyk/github/Home.Configuration/PTProjectsWeb.Firebase.ServiceAccount.json"
./gradlew bootRun
eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa
$env:GOOGLE_APPLICATION_CREDENTIALS="c:\bin\github\Home.Configuration\PTProjectsWeb.Firebase.ServiceAccount.json"
Add depdencies in build.gradle
implementation 'org.springframework.boot:spring-boot-starter-graphql'
enable UI for graph ql application.properties
spring.graphql.graphiql.enabled=true
package top.productivitytools.waypoint.api.controllers;
import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.MutationMapping;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.stereotype.Controller;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
public class HomeController {
@QueryMapping
public String helloQuery() {
return "Hello World";
}
@MutationMapping
public String Hello(@Argument("name") String name) {
var response = "Hello " + name;
return response;
}
}
Add graphql
type Mutation{
Hello(name: String!):String
}
type Query {
helloQuery: String
}
http://localhost:8080/graphiql
query {
helloQuery
}
mutation {
Hello(name: "Pawel")
}
gcloud builds submit .
gcloud artifacts repositories create waypoints-repo --repository-format=docker --location=us-central1 --description="Docker repository for Waypoints API"
gcloud builds submit --tag us-central1-docker.pkg.dev/ptprojectsweb/waypoints-repo/api .
gcloud run deploy pt-waypoints-api --image us-central1-docker.pkg.dev/ptprojectsweb/waypoints-repo/api --platform managed --region us-central1 --allow-unauthenticated
delete
gcloud run services delete waypoints-api --region us-central1
