Skip to content

Commit 55d35f9

Browse files
committed
add graphql modules and healthcheck api
1 parent 4a55688 commit 55d35f9

13 files changed

+2457
-49
lines changed

api/healthCheckApi.go

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,43 @@ package api
22

33
import (
44
"fmt"
5+
"log"
6+
"os/exec"
57
"runtime"
8+
"strings"
9+
10+
"github.com/neel1996/gitconvex-server/graph/model"
611
)
712

8-
func HealthCheckApi(){
9-
platform := runtime.GOOS
10-
fmt.Printf("The OS is : %v", platform)
13+
func getOs() string {
14+
return runtime.GOOS
15+
}
16+
17+
func getGitVersion() string {
18+
gitPath, err := exec.LookPath("git")
19+
20+
if err != nil {
21+
log.Printf("Git cannot be lovated \n %v", err)
22+
panic(err)
23+
}
24+
25+
gitCmd := &exec.Cmd{
26+
Path: gitPath,
27+
Args: []string{gitPath, "version"},
28+
}
29+
30+
gitVersion, err := gitCmd.Output()
31+
32+
if err != nil {
33+
fmt.Printf("Git version could not be obtained \n %v", err)
34+
}
35+
36+
return strings.Split(string(gitVersion), "\n")[0]
37+
}
38+
39+
func HealthCheckApi() *model.HealthCheckParams {
40+
return &model.HealthCheckParams{
41+
Os: getOs(),
42+
Git: getGitVersion(),
43+
}
1144
}

global/GraphQLSchema.go

Lines changed: 0 additions & 2 deletions
This file was deleted.

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/neel1996/gitconvex-server
33
go 1.15
44

55
require (
6+
github.com/99designs/gqlgen v0.13.0
67
github.com/gorilla/mux v1.8.0
7-
github.com/graphql-go/graphql v0.7.9 // indirect
8+
github.com/vektah/gqlparser/v2 v2.1.0
89
)

go.sum

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8
1414
github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
1515
github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
1616
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
17-
github.com/gorilla/mux v1.6.1 h1:KOwqsTYZdeuMacU7CxjMNYEKeBvLbxW+psodrbcEa3A=
1817
github.com/gorilla/mux v1.6.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
1918
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
2019
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
2120
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
2221
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
23-
github.com/graphql-go/graphql v0.7.9 h1:5Va/Rt4l5g3YjwDnid3vFfn43faaQBq7rMcIZ0VnV34=
24-
github.com/graphql-go/graphql v0.7.9/go.mod h1:k6yrAYQaSP59DC5UVxbgxESlmVyojThKdORUqGDGmrI=
2522
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
2623
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
2724
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=

gqlgen.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Where are all the schema files located? globs are supported eg src/**/*.graphqls
2+
schema:
3+
- graph/*.graphqls
4+
5+
# Where should the generated server code go?
6+
exec:
7+
filename: graph/generated/generated.go
8+
package: generated
9+
10+
# Uncomment to enable federation
11+
# federation:
12+
# filename: graph/generated/federation.go
13+
# package: generated
14+
15+
# Where should any generated models go?
16+
model:
17+
filename: graph/model/models_gen.go
18+
package: model
19+
20+
# Where should the resolver implementations go?
21+
resolver:
22+
layout: follow-schema
23+
dir: graph
24+
package: graph
25+
26+
# Optional: turn on use `gqlgen:"fieldName"` tags in your models
27+
# struct_tag: json
28+
29+
# Optional: turn on to use []Thing instead of []*Thing
30+
# omit_slice_element_pointers: false
31+
32+
# Optional: set to speed up generation time by not performing a final validation pass.
33+
# skip_validation: true
34+
35+
# gqlgen will search for any type names in the schema in these go packages
36+
# if they match it will use them, otherwise it will generate them.
37+
autobind:
38+
- "github.com/neel1996/gitconvex-server/graph/model"
39+
40+
# This section declares type mapping between the GraphQL and go type systems
41+
#
42+
# The first line in each type will be used as defaults for resolver arguments and
43+
# modelgen, the others will be allowed when binding to fields. Configure them to
44+
# your liking
45+
models:
46+
ID:
47+
model:
48+
- github.com/99designs/gqlgen/graphql.ID
49+
- github.com/99designs/gqlgen/graphql.Int
50+
- github.com/99designs/gqlgen/graphql.Int64
51+
- github.com/99designs/gqlgen/graphql.Int32
52+
Int:
53+
model:
54+
- github.com/99designs/gqlgen/graphql.Int
55+
- github.com/99designs/gqlgen/graphql.Int64
56+
- github.com/99designs/gqlgen/graphql.Int32

0 commit comments

Comments
 (0)