-
Notifications
You must be signed in to change notification settings - Fork 12
/
external_system.resolvers.go
45 lines (38 loc) · 2.04 KB
/
external_system.resolvers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package resolver
// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.
// Code generated by github.com/99designs/gqlgen version v0.17.46
import (
"context"
"github.com/99designs/gqlgen/graphql"
"github.com/openline-ai/openline-customer-os/packages/server/customer-os-api/graph/model"
"github.com/openline-ai/openline-customer-os/packages/server/customer-os-api/mapper"
"github.com/openline-ai/openline-customer-os/packages/server/customer-os-api/tracing"
"github.com/openline-ai/openline-customer-os/packages/server/customer-os-common-module/common"
)
// ExternalSystemCreate is the resolver for the externalSystem_Create field.
func (r *mutationResolver) ExternalSystemCreate(ctx context.Context, input model.ExternalSystemInput) (string, error) {
ctx, span := tracing.StartGraphQLTracerSpan(ctx, "QueryResolver.ExternalSystemCreate", graphql.GetOperationContext(ctx))
defer span.Finish()
tracing.SetDefaultResolverSpanTags(ctx, span)
err := r.Services.CommonServices.ExternalSystemService.MergeExternalSystem(ctx, common.GetTenantFromContext(ctx), input.Name)
if err != nil {
tracing.TraceErr(span, err)
graphql.AddErrorf(ctx, "Failed to merge external system")
return "", err
}
return input.Name, nil
}
// ExternalSystemInstances is the resolver for the externalSystemInstances field.
func (r *queryResolver) ExternalSystemInstances(ctx context.Context) ([]*model.ExternalSystemInstance, error) {
ctx, span := tracing.StartGraphQLTracerSpan(ctx, "QueryResolver.ExternalSystemInstances", graphql.GetOperationContext(ctx))
defer span.Finish()
tracing.SetDefaultResolverSpanTags(ctx, span)
externalSystemEntities, err := r.Services.ExternalSystemService.GetAllExternalSystemInstances(ctx)
if err != nil {
tracing.TraceErr(span, err)
graphql.AddErrorf(ctx, "Failed to get external system instances")
return nil, err
}
return mapper.MapExternalSystemEntitiesToExternalSystemInstances(externalSystemEntities), nil
}