Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
fix: return property with clusters data (#89)
Browse files Browse the repository at this point in the history
Co-authored-by: maherhamoui6 <hammimo022@gmail.com>
Co-authored-by: yk <yk.eukarya@gmail.com>
Co-authored-by: basel.issmail <basel.issmail@gmail.com>
Co-authored-by: rot1024 <aayhrot@gmail.com>
  • Loading branch information
5 people authored Dec 17, 2021
1 parent c4fb9a5 commit 1b99c6d
Show file tree
Hide file tree
Showing 16 changed files with 221 additions and 127 deletions.
44 changes: 22 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,62 @@ require (
cloud.google.com/go/storage v1.18.2
github.com/99designs/gqlgen v0.14.0
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.0.0
github.com/HdrHistogram/hdrhistogram-go v1.0.1 // indirect
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect
github.com/auth0/go-jwt-middleware v1.0.1
github.com/blang/semver v3.5.1+incompatible
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/dgryski/trifles v0.0.0-20200705224438-cafc02a1ee2b // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/form3tech-oss/jwt-go v3.2.2+incompatible
github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813 // indirect
github.com/goccy/go-yaml v1.9.4
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/iancoleman/strcase v0.2.0
github.com/idubinskiy/schematyper v0.0.0-20190118213059-f71b40dac30d
github.com/jarcoal/httpmock v1.0.8
github.com/joho/godotenv v1.4.0
github.com/jonas-p/go-shp v0.1.1
github.com/kelseyhightower/envconfig v1.4.0
github.com/kennygrant/sanitize v1.2.4
github.com/klauspost/compress v1.13.6 // indirect
github.com/labstack/echo/v4 v4.6.1
github.com/labstack/gommon v0.3.1
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/mapstructure v1.4.2
github.com/oklog/ulid v1.3.1
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/paulmach/go.geojson v1.4.0
github.com/pkg/errors v0.9.1
github.com/ravilushqa/otelgqlgen v0.2.0
github.com/sirupsen/logrus v1.8.1
github.com/smartystreets/assertions v1.1.1 // indirect
github.com/spf13/afero v1.6.0
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/tidwall/pretty v1.0.1 // indirect
github.com/twpayne/go-kml v1.5.2
github.com/uber/jaeger-client-go v2.29.1+incompatible
github.com/uber/jaeger-lib v2.4.1+incompatible
github.com/urfave/cli/v2 v2.3.0 // indirect
github.com/vektah/dataloaden v0.3.0
github.com/vektah/gqlparser/v2 v2.2.0
go.mongodb.org/mongo-driver v1.7.4
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.27.0
go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo v0.27.0
go.opentelemetry.io/otel v1.2.0
go.opentelemetry.io/otel/sdk v1.2.0
go.uber.org/atomic v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b // indirect
golang.org/x/text v0.3.7
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
golang.org/x/tools v0.1.7
google.golang.org/api v0.60.0
gopkg.in/go-playground/colors.v1 v1.2.0
gopkg.in/h2non/gock.v1 v1.1.2
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

require (
cloud.google.com/go v0.97.0 // indirect
cloud.google.com/go/trace v1.0.0 // indirect
github.com/HdrHistogram/hdrhistogram-go v1.0.1 // indirect
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 // indirect
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/trifles v0.0.0-20200705224438-cafc02a1ee2b // indirect
github.com/envoyproxy/go-control-plane v0.10.0 // indirect
github.com/envoyproxy/protoc-gen-validate v0.6.2 // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -86,10 +71,18 @@ require (
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/mattn/go-colorable v0.1.11 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/smartystreets/assertions v1.1.1 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/tidwall/pretty v1.0.1 // indirect
github.com/urfave/cli/v2 v2.3.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
Expand All @@ -99,16 +92,23 @@ require (
go.opencensus.io v0.23.0 // indirect
go.opentelemetry.io/contrib v0.23.0 // indirect
go.opentelemetry.io/otel/trace v1.2.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/net v0.0.0-20211101193420-4a448f8816b3 // indirect
golang.org/x/oauth2 v0.0.0-20211028175245-ba495a64dcb5 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20211101144312-62acf1d99145 // indirect
google.golang.org/grpc v1.41.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

go 1.17
87 changes: 67 additions & 20 deletions internal/adapter/gql/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/adapter/gql/gqlmodel/convert_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func ToScenePlugin(sp *scene.Plugin) *ScenePlugin {

func ToCluster(c *scene.Cluster) *Cluster {
return &Cluster{
ID: c.ID().ID(),
Name: c.Name(),
Property: c.Property().ID(),
ID: c.ID().ID(),
Name: c.Name(),
PropertyID: c.Property().ID(),
}
}

Expand Down
12 changes: 6 additions & 6 deletions internal/adapter/gql/gqlmodel/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/adapter/gql/resolver_mutation_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (r *mutationResolver) UpgradePlugin(ctx context.Context, input gqlmodel.Upg
func (r *mutationResolver) AddCluster(ctx context.Context, input gqlmodel.AddClusterInput) (*gqlmodel.AddClusterPayload, error) {
exit := trace(ctx)
defer exit()
s, c, err := r.usecases.Scene.AddCluster(ctx, id.SceneID(input.SceneID), input.Name, id.PropertyID(input.PropertyID), getOperator(ctx))
s, c, err := r.usecases.Scene.AddCluster(ctx, id.SceneID(input.SceneID), input.Name, getOperator(ctx))
if err != nil {
return nil, err
}
Expand Down
13 changes: 13 additions & 0 deletions internal/adapter/gql/resolver_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func (r *Resolver) SceneWidget() SceneWidgetResolver {
return &sceneWidgetResolver{r}
}

func (r *Resolver) Cluster() ClusterResolver {
return &clusterResolver{r}
}

type sceneResolver struct{ *Resolver }

func (r *sceneResolver) Project(ctx context.Context, obj *gqlmodel.Scene) (*gqlmodel.Project, error) {
Expand Down Expand Up @@ -144,3 +148,12 @@ func (r *sceneWidgetResolver) Property(ctx context.Context, obj *gqlmodel.SceneW

return DataLoadersFromContext(ctx).Property.Load(id.PropertyID(obj.PropertyID))
}

type clusterResolver struct{ *Resolver }

func (r *clusterResolver) Property(ctx context.Context, obj *gqlmodel.Cluster) (*gqlmodel.Property, error) {
exit := trace(ctx)
defer exit()

return DataLoadersFromContext(ctx).Property.Load(id.PropertyID(obj.PropertyID))
}
Loading

0 comments on commit 1b99c6d

Please sign in to comment.