// Code generated by candi v1.8.17.

package graphqlhandler

import (
	"context"

	shareddomain "monorepo/services/user-service/pkg/shared/domain"

	"pkg.agungdp.dev/candi/tracer"
)

type queryResolver struct {
	root *GraphQLHandler
}

// GetAllMember resolver
func (q *queryResolver) GetAllMember(ctx context.Context, input struct{ Filter *CommonFilter }) (results MemberListResolver, err error) {
	trace := tracer.StartTrace(ctx, "MemberDeliveryGraphQL:GetAllMember")
	defer trace.Finish()
	ctx = trace.Context()

	// tokenClaim := candishared.ParseTokenClaimFromContext(ctx) // must using GraphQLBearerAuth in middleware for this resolver

	if input.Filter == nil {
		input.Filter = new(CommonFilter)
	}
	filter := input.Filter.toSharedFilter()
	data, meta, err := q.root.uc.GetAllMember(ctx, filter)
	if err != nil {
		return results, err
	}

	return MemberListResolver{
		Meta: meta, Data: data,
	}, nil
}

// GetDetailMember resolver
func (q *queryResolver) GetDetailMember(ctx context.Context, input struct{ ID string }) (data shareddomain.Member, err error) {
	trace := tracer.StartTrace(ctx, "MemberDeliveryGraphQL:GetDetailMember")
	defer trace.Finish()
	ctx = trace.Context()

	// tokenClaim := candishared.ParseTokenClaimFromContext(ctx) // must using GraphQLBearerAuth in middleware for this resolver

	return q.root.uc.GetDetailMember(ctx, input.ID)
}
