Sample Hello Application demostrate following modules:
- gateway-hello-graphql
implements graphql query and mutation for Hello by calling grpc apis provided by micro-hello-grpc
- micro-hello-grpc
implements grpc micro service for Hello CRUD
- Refer to Google API Design Guide
- Refer to Google real life example servicemanager.proto
- And local copy of Google real life example servicemanager.proto
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
https://jitpack.io/com/github/conanchen/guoi-micro-apis/master-SNAPSHOT/build.log
Build artifacts:
...
com.github.conanchen.guoi-micro-apis:hello-grpc-java:master-5efdd7e810-1
...
configurations.all {
//每隔10分钟..
resolutionStrategy.cacheChangingModulesFor 10, 'minutes'
}
dependencies {
compile ("com.github.conanchen.guoi-micro-apis:authcow-grpc-java:master-SNAPSHOT"){ changing = true }
compile ("com.github.conanchen.guoi-micro-apis:gis-asset-grpc-java:master-SNAPSHOT"){ changing = true }
}
export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;
gradle build --refresh-dependencies -x test
Step 1. open browser http://localhost:9000/graphiql
{
hellos(first: 3) {
edges {
cursor
node {
id
lastName
firstName
message
}
}
}
}
{
"data": {
"hellos": {
"edges": [
{
"cursor": "aGVsbG9zLzk0ODFhODJjLWJiNDMtNGMzZi04OTE2LTUwMmM5NTFkMDdjZg==",
"node": {
"id": "hellos/9481a82c-bb43-4c3f-8916-502c951d07cf",
"lastName": "unknown",
"firstName": "unknown",
"message": "Hello conan, Welcome to Guoi Micro$!"
}
},
{
"cursor": "aGVsbG9zLzlmZjU3NTlhLTc3YmItNDJkYi05NzJiLWFhOTg4NTdmNTdhMQ==",
"node": {
"id": "hellos/9ff5759a-77bb-42db-972b-aa98857f57a1",
"lastName": "unknown",
"firstName": "unknown",
"message": "Hello lihai, Welcome to Guoi Micro$!"
}
}
]
}
}
}
- mutation
mutation ($input:HelloCreateInput!){
hello0Create(input:$input){
hello{
id
firstName
lastName
message
}
}
}
- Query Variables
{
"input": {
"firstName": "conan",
"lastName": "chen"
}
}
{
"data": {
"hello0Create": {
"hello": {
"id": "hellos/83ffb798-f44b-42ae-beca-036a1b486b96",
"message": "Hello chen conan, Welcome to Guoi Micro$!",
"create_time": "2018-04-06T07:36:10.935Z",
"update_time": "2018-04-06T07:36:10.935Z"
}
}
}
}
On Windows if you encounter bellow errors:
Caused by: java.io.IOException: Could not open inputStream for https://downloads.mongodb.org/win32/mongodb-win32-x86_64-3.2.2.zip
at de.flapdoodle.embed.process.store.Downloader.downloadInputStream(Downloader.java:131)
at de.flapdoodle.embed.process.store.Downloader.download(Downloader.java:69)
at de.flapdoodle.embed.process.store.ArtifactStore.checkDistribution(ArtifactStore.java:66)
at de.flapdoodle.embed.process.store.ExtractedArtifactStore.checkDistribution(ExtractedArtifactStore.java:60)
You can also build snapshots on each commit if you add GitHub Webhooks.
To add, head to repository Settings -> Webhooks & Services -> Add webhook.
Webhook URL: https://jitpack.io/api/webhooks
Content type: application/json
The webhook will trigger a build for branches that you have previously used with JitPack. So make sure you have requested master-SNAPSHOT from JitPack before adding a webhook.