From 0173aa2188b90dfb16502cbb78c707ab0ad07c3d Mon Sep 17 00:00:00 2001 From: alonkeyval Date: Mon, 5 Aug 2024 15:40:57 +0300 Subject: [PATCH] chore: init get destination type query --- frontend/graph/generated.go | 775 +++++++++++++++++++++++++++-- frontend/graph/model/models_gen.go | 14 + frontend/graph/schema.graphqls | 15 + frontend/graph/schema.resolvers.go | 30 +- frontend/services/destinations.go | 12 + 5 files changed, 804 insertions(+), 42 deletions(-) diff --git a/frontend/graph/generated.go b/frontend/graph/generated.go index ab9a757eb..bd2077fec 100644 --- a/frontend/graph/generated.go +++ b/frontend/graph/generated.go @@ -97,10 +97,24 @@ type ComplexityRoot struct { Traces func(childComplexity int) int } + Field struct { + ComponentProperties func(childComplexity int) int + ComponentType func(childComplexity int) int + DisplayName func(childComplexity int) int + InitialValue func(childComplexity int) int + Name func(childComplexity int) int + ThumbnailURL func(childComplexity int) int + VideoURL func(childComplexity int) int + } + GetConfigResponse struct { Installation func(childComplexity int) int } + GetDestinationDetailsResponse struct { + Fields func(childComplexity int) int + } + GetDestinationTypesResponse struct { Categories func(childComplexity int) int } @@ -136,9 +150,10 @@ type ComplexityRoot struct { } Query struct { - ComputePlatform func(childComplexity int) int - Config func(childComplexity int) int - DestinationTypes func(childComplexity int) int + ComputePlatform func(childComplexity int) int + Config func(childComplexity int) int + DestinationTypeDetails func(childComplexity int, typeArg string) int + DestinationTypes func(childComplexity int) int } SourceContainerRuntimeDetails struct { @@ -178,6 +193,7 @@ type QueryResolver interface { ComputePlatform(ctx context.Context) (*model.ComputePlatform, error) Config(ctx context.Context) (*model.GetConfigResponse, error) DestinationTypes(ctx context.Context) (*model.GetDestinationTypesResponse, error) + DestinationTypeDetails(ctx context.Context, typeArg string) (*model.GetDestinationDetailsResponse, error) } type executableSchema struct { @@ -405,6 +421,55 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ExportedSignals.Traces(childComplexity), true + case "Field.componentProperties": + if e.complexity.Field.ComponentProperties == nil { + break + } + + return e.complexity.Field.ComponentProperties(childComplexity), true + + case "Field.componentType": + if e.complexity.Field.ComponentType == nil { + break + } + + return e.complexity.Field.ComponentType(childComplexity), true + + case "Field.displayName": + if e.complexity.Field.DisplayName == nil { + break + } + + return e.complexity.Field.DisplayName(childComplexity), true + + case "Field.initialValue": + if e.complexity.Field.InitialValue == nil { + break + } + + return e.complexity.Field.InitialValue(childComplexity), true + + case "Field.name": + if e.complexity.Field.Name == nil { + break + } + + return e.complexity.Field.Name(childComplexity), true + + case "Field.thumbnailURL": + if e.complexity.Field.ThumbnailURL == nil { + break + } + + return e.complexity.Field.ThumbnailURL(childComplexity), true + + case "Field.videoUrl": + if e.complexity.Field.VideoURL == nil { + break + } + + return e.complexity.Field.VideoURL(childComplexity), true + case "GetConfigResponse.installation": if e.complexity.GetConfigResponse.Installation == nil { break @@ -412,6 +477,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.GetConfigResponse.Installation(childComplexity), true + case "GetDestinationDetailsResponse.fields": + if e.complexity.GetDestinationDetailsResponse.Fields == nil { + break + } + + return e.complexity.GetDestinationDetailsResponse.Fields(childComplexity), true + case "GetDestinationTypesResponse.categories": if e.complexity.GetDestinationTypesResponse.Categories == nil { break @@ -548,6 +620,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Config(childComplexity), true + case "Query.destinationTypeDetails": + if e.complexity.Query.DestinationTypeDetails == nil { + break + } + + args, err := ec.field_Query_destinationTypeDetails_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.DestinationTypeDetails(childComplexity, args["type"].(string)), true + case "Query.destinationTypes": if e.complexity.Query.DestinationTypes == nil { break @@ -820,6 +904,21 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) field_Query_destinationTypeDetails_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["type"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("type")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["type"] = arg0 + return args, nil +} + func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2063,8 +2162,357 @@ func (ec *executionContext) fieldContext_DestinationsCategory_items(_ context.Co return fc, nil } -func (ec *executionContext) _ExportedSignals_traces(ctx context.Context, field graphql.CollectedField, obj *model.ExportedSignals) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ExportedSignals_traces(ctx, field) +func (ec *executionContext) _ExportedSignals_traces(ctx context.Context, field graphql.CollectedField, obj *model.ExportedSignals) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ExportedSignals_traces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Traces, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ExportedSignals_traces(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ExportedSignals", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ExportedSignals_metrics(ctx context.Context, field graphql.CollectedField, obj *model.ExportedSignals) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ExportedSignals_metrics(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Metrics, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ExportedSignals_metrics(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ExportedSignals", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ExportedSignals_logs(ctx context.Context, field graphql.CollectedField, obj *model.ExportedSignals) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ExportedSignals_logs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Logs, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ExportedSignals_logs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ExportedSignals", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Field_name(ctx context.Context, field graphql.CollectedField, obj *model.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Field_name(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Field_displayName(ctx context.Context, field graphql.CollectedField, obj *model.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Field_displayName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DisplayName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Field_displayName(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Field_componentType(ctx context.Context, field graphql.CollectedField, obj *model.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Field_componentType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ComponentType, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Field_componentType(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Field_componentProperties(ctx context.Context, field graphql.CollectedField, obj *model.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Field_componentProperties(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ComponentProperties, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Field_componentProperties(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Field_videoUrl(ctx context.Context, field graphql.CollectedField, obj *model.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Field_videoUrl(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.VideoURL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Field_videoUrl(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Field_thumbnailURL(ctx context.Context, field graphql.CollectedField, obj *model.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Field_thumbnailURL(ctx, field) if err != nil { return graphql.Null } @@ -2077,38 +2525,35 @@ func (ec *executionContext) _ExportedSignals_traces(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Traces, nil + return obj.ThumbnailURL, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ExportedSignals_traces(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Field_thumbnailURL(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ExportedSignals", + Object: "Field", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _ExportedSignals_metrics(ctx context.Context, field graphql.CollectedField, obj *model.ExportedSignals) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ExportedSignals_metrics(ctx, field) +func (ec *executionContext) _Field_initialValue(ctx context.Context, field graphql.CollectedField, obj *model.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Field_initialValue(ctx, field) if err != nil { return graphql.Null } @@ -2121,38 +2566,35 @@ func (ec *executionContext) _ExportedSignals_metrics(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Metrics, nil + return obj.InitialValue, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(*string) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ExportedSignals_metrics(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Field_initialValue(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ExportedSignals", + Object: "Field", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _ExportedSignals_logs(ctx context.Context, field graphql.CollectedField, obj *model.ExportedSignals) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ExportedSignals_logs(ctx, field) +func (ec *executionContext) _GetConfigResponse_installation(ctx context.Context, field graphql.CollectedField, obj *model.GetConfigResponse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetConfigResponse_installation(ctx, field) if err != nil { return graphql.Null } @@ -2165,7 +2607,7 @@ func (ec *executionContext) _ExportedSignals_logs(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Logs, nil + return obj.Installation, nil }) if err != nil { ec.Error(ctx, err) @@ -2177,26 +2619,26 @@ func (ec *executionContext) _ExportedSignals_logs(ctx context.Context, field gra } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(model.InstallationStatus) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNInstallationStatus2githubᚗcomᚋodigosᚑioᚋodigosᚋfrontendᚋgraphᚋmodelᚐInstallationStatus(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ExportedSignals_logs(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetConfigResponse_installation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ExportedSignals", + Object: "GetConfigResponse", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type InstallationStatus does not have child fields") }, } return fc, nil } -func (ec *executionContext) _GetConfigResponse_installation(ctx context.Context, field graphql.CollectedField, obj *model.GetConfigResponse) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_GetConfigResponse_installation(ctx, field) +func (ec *executionContext) _GetDestinationDetailsResponse_fields(ctx context.Context, field graphql.CollectedField, obj *model.GetDestinationDetailsResponse) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_GetDestinationDetailsResponse_fields(ctx, field) if err != nil { return graphql.Null } @@ -2209,7 +2651,7 @@ func (ec *executionContext) _GetConfigResponse_installation(ctx context.Context, }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Installation, nil + return obj.Fields, nil }) if err != nil { ec.Error(ctx, err) @@ -2221,19 +2663,35 @@ func (ec *executionContext) _GetConfigResponse_installation(ctx context.Context, } return graphql.Null } - res := resTmp.(model.InstallationStatus) + res := resTmp.([]*model.Field) fc.Result = res - return ec.marshalNInstallationStatus2githubᚗcomᚋodigosᚑioᚋodigosᚋfrontendᚋgraphᚋmodelᚐInstallationStatus(ctx, field.Selections, res) + return ec.marshalNField2ᚕᚖgithubᚗcomᚋodigosᚑioᚋodigosᚋfrontendᚋgraphᚋmodelᚐFieldᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_GetConfigResponse_installation(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_GetDestinationDetailsResponse_fields(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "GetConfigResponse", + Object: "GetDestinationDetailsResponse", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type InstallationStatus does not have child fields") + switch field.Name { + case "name": + return ec.fieldContext_Field_name(ctx, field) + case "displayName": + return ec.fieldContext_Field_displayName(ctx, field) + case "componentType": + return ec.fieldContext_Field_componentType(ctx, field) + case "componentProperties": + return ec.fieldContext_Field_componentProperties(ctx, field) + case "videoUrl": + return ec.fieldContext_Field_videoUrl(ctx, field) + case "thumbnailURL": + return ec.fieldContext_Field_thumbnailURL(ctx, field) + case "initialValue": + return ec.fieldContext_Field_initialValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Field", field.Name) }, } return fc, nil @@ -3145,6 +3603,62 @@ func (ec *executionContext) fieldContext_Query_destinationTypes(_ context.Contex return fc, nil } +func (ec *executionContext) _Query_destinationTypeDetails(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_destinationTypeDetails(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DestinationTypeDetails(rctx, fc.Args["type"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.GetDestinationDetailsResponse) + fc.Result = res + return ec.marshalOGetDestinationDetailsResponse2ᚖgithubᚗcomᚋodigosᚑioᚋodigosᚋfrontendᚋgraphᚋmodelᚐGetDestinationDetailsResponse(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_destinationTypeDetails(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "fields": + return ec.fieldContext_GetDestinationDetailsResponse_fields(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type GetDestinationDetailsResponse", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_destinationTypeDetails_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { @@ -5925,6 +6439,66 @@ func (ec *executionContext) _ExportedSignals(ctx context.Context, sel ast.Select return out } +var fieldImplementors = []string{"Field"} + +func (ec *executionContext) _Field(ctx context.Context, sel ast.SelectionSet, obj *model.Field) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, fieldImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Field") + case "name": + out.Values[i] = ec._Field_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "displayName": + out.Values[i] = ec._Field_displayName(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "componentType": + out.Values[i] = ec._Field_componentType(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "componentProperties": + out.Values[i] = ec._Field_componentProperties(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "videoUrl": + out.Values[i] = ec._Field_videoUrl(ctx, field, obj) + case "thumbnailURL": + out.Values[i] = ec._Field_thumbnailURL(ctx, field, obj) + case "initialValue": + out.Values[i] = ec._Field_initialValue(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var getConfigResponseImplementors = []string{"GetConfigResponse"} func (ec *executionContext) _GetConfigResponse(ctx context.Context, sel ast.SelectionSet, obj *model.GetConfigResponse) graphql.Marshaler { @@ -5964,6 +6538,45 @@ func (ec *executionContext) _GetConfigResponse(ctx context.Context, sel ast.Sele return out } +var getDestinationDetailsResponseImplementors = []string{"GetDestinationDetailsResponse"} + +func (ec *executionContext) _GetDestinationDetailsResponse(ctx context.Context, sel ast.SelectionSet, obj *model.GetDestinationDetailsResponse) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, getDestinationDetailsResponseImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("GetDestinationDetailsResponse") + case "fields": + out.Values[i] = ec._GetDestinationDetailsResponse_fields(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var getDestinationTypesResponseImplementors = []string{"GetDestinationTypesResponse"} func (ec *executionContext) _GetDestinationTypesResponse(ctx context.Context, sel ast.SelectionSet, obj *model.GetDestinationTypesResponse) graphql.Marshaler { @@ -6343,6 +6956,25 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "destinationTypeDetails": + field := field + + innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_destinationTypeDetails(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { @@ -6939,6 +7571,60 @@ func (ec *executionContext) marshalNExportedSignals2githubᚗcomᚋodigosᚑio return ec._ExportedSignals(ctx, sel, &v) } +func (ec *executionContext) marshalNField2ᚕᚖgithubᚗcomᚋodigosᚑioᚋodigosᚋfrontendᚋgraphᚋmodelᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Field) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNField2ᚖgithubᚗcomᚋodigosᚑioᚋodigosᚋfrontendᚋgraphᚋmodelᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNField2ᚖgithubᚗcomᚋodigosᚑioᚋodigosᚋfrontendᚋgraphᚋmodelᚐField(ctx context.Context, sel ast.SelectionSet, v *model.Field) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Field(ctx, sel, v) +} + func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalID(v) return res, graphql.ErrorOnPath(ctx, err) @@ -7460,6 +8146,13 @@ func (ec *executionContext) marshalOGetConfigResponse2ᚖgithubᚗcomᚋodigos return ec._GetConfigResponse(ctx, sel, v) } +func (ec *executionContext) marshalOGetDestinationDetailsResponse2ᚖgithubᚗcomᚋodigosᚑioᚋodigosᚋfrontendᚋgraphᚋmodelᚐGetDestinationDetailsResponse(ctx context.Context, sel ast.SelectionSet, v *model.GetDestinationDetailsResponse) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._GetDestinationDetailsResponse(ctx, sel, v) +} + func (ec *executionContext) marshalOGetDestinationTypesResponse2ᚖgithubᚗcomᚋodigosᚑioᚋodigosᚋfrontendᚋgraphᚋmodelᚐGetDestinationTypesResponse(ctx context.Context, sel ast.SelectionSet, v *model.GetDestinationTypesResponse) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/frontend/graph/model/models_gen.go b/frontend/graph/model/models_gen.go index 8edb3f653..e74ae4c57 100644 --- a/frontend/graph/model/models_gen.go +++ b/frontend/graph/model/models_gen.go @@ -25,10 +25,24 @@ type Condition struct { Message *string `json:"message,omitempty"` } +type Field struct { + Name string `json:"name"` + DisplayName string `json:"displayName"` + ComponentType string `json:"componentType"` + ComponentProperties string `json:"componentProperties"` + VideoURL *string `json:"videoUrl,omitempty"` + ThumbnailURL *string `json:"thumbnailURL,omitempty"` + InitialValue *string `json:"initialValue,omitempty"` +} + type GetConfigResponse struct { Installation InstallationStatus `json:"installation"` } +type GetDestinationDetailsResponse struct { + Fields []*Field `json:"fields"` +} + type InstrumentedApplicationDetails struct { Containers []*SourceContainerRuntimeDetails `json:"containers,omitempty"` Conditions []*Condition `json:"conditions,omitempty"` diff --git a/frontend/graph/schema.graphqls b/frontend/graph/schema.graphqls index a1d5d0abc..591e81151 100644 --- a/frontend/graph/schema.graphqls +++ b/frontend/graph/schema.graphqls @@ -158,10 +158,25 @@ type GetConfigResponse { installation: InstallationStatus! } +type Field { + name: String! + displayName: String! + componentType: String! + componentProperties: String! # Using String to store JSON data as a string + videoUrl: String + thumbnailURL: String + initialValue: String +} + +type GetDestinationDetailsResponse { + fields: [Field!]! +} + type Query { computePlatform: ComputePlatform config: GetConfigResponse destinationTypes: GetDestinationTypesResponse + destinationTypeDetails(type: String!): GetDestinationDetailsResponse } type Mutation { diff --git a/frontend/graph/schema.resolvers.go b/frontend/graph/schema.resolvers.go index f32fbfbf4..e8e75addb 100644 --- a/frontend/graph/schema.resolvers.go +++ b/frontend/graph/schema.resolvers.go @@ -6,8 +6,10 @@ package graph import ( "context" + "encoding/json" "fmt" + "github.com/odigos-io/odigos/common" "github.com/odigos-io/odigos/frontend/endpoints" "github.com/odigos-io/odigos/frontend/graph/model" "github.com/odigos-io/odigos/frontend/kube" @@ -117,11 +119,37 @@ func (r *queryResolver) Config(ctx context.Context) (*model.GetConfigResponse, e // DestinationTypes is the resolver for the destinationTypes field. func (r *queryResolver) DestinationTypes(ctx context.Context) (*model.GetDestinationTypesResponse, error) { - destTypes := services.GetDestinationTypes() return &destTypes, nil +} + +// DestinationTypeDetails is the resolver for the destinationTypeDetails field. +func (r *queryResolver) DestinationTypeDetails(ctx context.Context, typeArg string) (*model.GetDestinationDetailsResponse, error) { + destType := common.DestinationType(typeArg) + destTypeConfig, err := services.GetDestinationTypeConfig(destType) + if err != nil { + return nil, fmt.Errorf("destination type %s not found", destType) + } + + var resp model.GetDestinationDetailsResponse + for _, field := range destTypeConfig.Spec.Fields { + componentPropsJSON, err := json.Marshal(field.ComponentProps) + if err != nil { + return nil, fmt.Errorf("error marshalling component properties: %v", err) + } + + resp.Fields = append(resp.Fields, &model.Field{ + Name: field.Name, + DisplayName: field.DisplayName, + ComponentType: field.ComponentType, + ComponentProperties: string(componentPropsJSON), + InitialValue: &field.InitialValue, + }) + + } + return &resp, nil } // ComputePlatform returns ComputePlatformResolver implementation. diff --git a/frontend/services/destinations.go b/frontend/services/destinations.go index a1d0b5b09..39e7835e8 100644 --- a/frontend/services/destinations.go +++ b/frontend/services/destinations.go @@ -1,6 +1,8 @@ package services import ( + "fmt" + "github.com/odigos-io/odigos/common" "github.com/odigos-io/odigos/destinations" "github.com/odigos-io/odigos/frontend/graph/model" @@ -47,3 +49,13 @@ func DestinationTypeConfigToCategoryItem(destConfig destinations.Destination) mo } } + +func GetDestinationTypeConfig(destType common.DestinationType) (*destinations.Destination, error) { + for _, dest := range destinations.Get() { + if dest.Metadata.Type == destType { + return &dest, nil + } + } + + return nil, fmt.Errorf("destination type %s not found", destType) +}