-
Notifications
You must be signed in to change notification settings - Fork 12
/
social.resolvers.go
47 lines (40 loc) · 1.95 KB
/
social.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
46
47
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/opentracing/opentracing-go/log"
)
// SocialUpdate is the resolver for the social_Update field.
func (r *mutationResolver) SocialUpdate(ctx context.Context, input model.SocialUpdateInput) (*model.Social, error) {
ctx, span := tracing.StartGraphQLTracerSpan(ctx, "MutationResolver.SocialUpdate", graphql.GetOperationContext(ctx))
defer span.Finish()
tracing.SetDefaultResolverSpanTags(ctx, span)
span.LogFields(log.String("request.socialID", input.ID))
socialEntity, err := r.Services.SocialService.Update(ctx, *mapper.MapSocialUpdateInputToEntity(&input))
if err != nil {
tracing.TraceErr(span, err)
graphql.AddErrorf(ctx, "Failed to update social")
return nil, err
}
return mapper.MapEntityToSocial(socialEntity), nil
}
// SocialRemove is the resolver for the social_Remove field.
func (r *mutationResolver) SocialRemove(ctx context.Context, socialID string) (*model.Result, error) {
ctx, span := tracing.StartGraphQLTracerSpan(ctx, "MutationResolver.SocialRemove", graphql.GetOperationContext(ctx))
defer span.Finish()
tracing.SetDefaultResolverSpanTags(ctx, span)
span.LogFields(log.String("request.socialID", socialID))
err := r.Services.SocialService.Remove(ctx, socialID)
if err != nil {
tracing.TraceErr(span, err)
graphql.AddErrorf(ctx, "Failed to remove social")
return &model.Result{Result: false}, nil
}
return &model.Result{Result: true}, nil
}