@@ -252,7 +252,7 @@ type Membership implements Node {
|
|||||||
active: Boolean!
|
active: Boolean!
|
||||||
lastSyncedAt: Datetime
|
lastSyncedAt: Datetime
|
||||||
|
|
||||||
activeSession: Session @goField(forceResolver: true) @isViewer
|
lastSession: Session @goField(forceResolver: true) @isViewer
|
||||||
}
|
}
|
||||||
|
|
||||||
type Invitation implements Node {
|
type Invitation implements Node {
|
||||||
|
|||||||
@@ -193,11 +193,11 @@ type ComplexityRoot struct {
|
|||||||
|
|
||||||
Membership struct {
|
Membership struct {
|
||||||
Active func(childComplexity int) int
|
Active func(childComplexity int) int
|
||||||
ActiveSession func(childComplexity int) int
|
|
||||||
CreatedAt func(childComplexity int) int
|
CreatedAt func(childComplexity int) int
|
||||||
ID func(childComplexity int) int
|
ID func(childComplexity int) int
|
||||||
Identity func(childComplexity int) int
|
Identity func(childComplexity int) int
|
||||||
IdentityID func(childComplexity int) int
|
IdentityID func(childComplexity int) int
|
||||||
|
LastSession func(childComplexity int) int
|
||||||
LastSyncedAt func(childComplexity int) int
|
LastSyncedAt func(childComplexity int) int
|
||||||
Organization func(childComplexity int) int
|
Organization func(childComplexity int) int
|
||||||
Permissions func(childComplexity int) int
|
Permissions func(childComplexity int) int
|
||||||
@@ -467,7 +467,7 @@ type MembershipResolver interface {
|
|||||||
Identity(ctx context.Context, obj *types.Membership) (*types.Identity, error)
|
Identity(ctx context.Context, obj *types.Membership) (*types.Identity, error)
|
||||||
Organization(ctx context.Context, obj *types.Membership) (*types.Organization, error)
|
Organization(ctx context.Context, obj *types.Membership) (*types.Organization, error)
|
||||||
|
|
||||||
ActiveSession(ctx context.Context, obj *types.Membership) (*types.Session, error)
|
LastSession(ctx context.Context, obj *types.Membership) (*types.Session, error)
|
||||||
}
|
}
|
||||||
type MembershipConnectionResolver interface {
|
type MembershipConnectionResolver interface {
|
||||||
TotalCount(ctx context.Context, obj *types.MembershipConnection) (int, error)
|
TotalCount(ctx context.Context, obj *types.MembershipConnection) (int, error)
|
||||||
@@ -972,12 +972,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
return e.complexity.Membership.Active(childComplexity), true
|
return e.complexity.Membership.Active(childComplexity), true
|
||||||
case "Membership.activeSession":
|
|
||||||
if e.complexity.Membership.ActiveSession == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
return e.complexity.Membership.ActiveSession(childComplexity), true
|
|
||||||
case "Membership.createdAt":
|
case "Membership.createdAt":
|
||||||
if e.complexity.Membership.CreatedAt == nil {
|
if e.complexity.Membership.CreatedAt == nil {
|
||||||
break
|
break
|
||||||
@@ -1002,6 +996,12 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
return e.complexity.Membership.IdentityID(childComplexity), true
|
return e.complexity.Membership.IdentityID(childComplexity), true
|
||||||
|
case "Membership.lastSession":
|
||||||
|
if e.complexity.Membership.LastSession == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.complexity.Membership.LastSession(childComplexity), true
|
||||||
case "Membership.lastSyncedAt":
|
case "Membership.lastSyncedAt":
|
||||||
if e.complexity.Membership.LastSyncedAt == nil {
|
if e.complexity.Membership.LastSyncedAt == nil {
|
||||||
break
|
break
|
||||||
@@ -2411,7 +2411,7 @@ type Membership implements Node {
|
|||||||
active: Boolean!
|
active: Boolean!
|
||||||
lastSyncedAt: Datetime
|
lastSyncedAt: Datetime
|
||||||
|
|
||||||
activeSession: Session @goField(forceResolver: true) @isViewer
|
lastSession: Session @goField(forceResolver: true) @isViewer
|
||||||
}
|
}
|
||||||
|
|
||||||
type Invitation implements Node {
|
type Invitation implements Node {
|
||||||
@@ -6227,14 +6227,14 @@ func (ec *executionContext) fieldContext_Membership_lastSyncedAt(_ context.Conte
|
|||||||
return fc, nil
|
return fc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _Membership_activeSession(ctx context.Context, field graphql.CollectedField, obj *types.Membership) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Membership_lastSession(ctx context.Context, field graphql.CollectedField, obj *types.Membership) (ret graphql.Marshaler) {
|
||||||
return graphql.ResolveField(
|
return graphql.ResolveField(
|
||||||
ctx,
|
ctx,
|
||||||
ec.OperationContext,
|
ec.OperationContext,
|
||||||
field,
|
field,
|
||||||
ec.fieldContext_Membership_activeSession,
|
ec.fieldContext_Membership_lastSession,
|
||||||
func(ctx context.Context) (any, error) {
|
func(ctx context.Context) (any, error) {
|
||||||
return ec.resolvers.Membership().ActiveSession(ctx, obj)
|
return ec.resolvers.Membership().LastSession(ctx, obj)
|
||||||
},
|
},
|
||||||
func(ctx context.Context, next graphql.Resolver) graphql.Resolver {
|
func(ctx context.Context, next graphql.Resolver) graphql.Resolver {
|
||||||
directive0 := next
|
directive0 := next
|
||||||
@@ -6256,7 +6256,7 @@ func (ec *executionContext) _Membership_activeSession(ctx context.Context, field
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) fieldContext_Membership_activeSession(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
func (ec *executionContext) fieldContext_Membership_lastSession(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||||
fc = &graphql.FieldContext{
|
fc = &graphql.FieldContext{
|
||||||
Object: "Membership",
|
Object: "Membership",
|
||||||
Field: field,
|
Field: field,
|
||||||
@@ -6432,8 +6432,8 @@ func (ec *executionContext) fieldContext_MembershipEdge_node(_ context.Context,
|
|||||||
return ec.fieldContext_Membership_active(ctx, field)
|
return ec.fieldContext_Membership_active(ctx, field)
|
||||||
case "lastSyncedAt":
|
case "lastSyncedAt":
|
||||||
return ec.fieldContext_Membership_lastSyncedAt(ctx, field)
|
return ec.fieldContext_Membership_lastSyncedAt(ctx, field)
|
||||||
case "activeSession":
|
case "lastSession":
|
||||||
return ec.fieldContext_Membership_activeSession(ctx, field)
|
return ec.fieldContext_Membership_lastSession(ctx, field)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("no field named %q was found under type Membership", field.Name)
|
return nil, fmt.Errorf("no field named %q was found under type Membership", field.Name)
|
||||||
},
|
},
|
||||||
@@ -8529,6 +8529,8 @@ func (ec *executionContext) fieldContext_OrganizationSessionCreated_membership(_
|
|||||||
return ec.fieldContext_Membership_identity(ctx, field)
|
return ec.fieldContext_Membership_identity(ctx, field)
|
||||||
case "organization":
|
case "organization":
|
||||||
return ec.fieldContext_Membership_organization(ctx, field)
|
return ec.fieldContext_Membership_organization(ctx, field)
|
||||||
|
case "role":
|
||||||
|
return ec.fieldContext_Membership_role(ctx, field)
|
||||||
case "permissions":
|
case "permissions":
|
||||||
return ec.fieldContext_Membership_permissions(ctx, field)
|
return ec.fieldContext_Membership_permissions(ctx, field)
|
||||||
case "provisionedBy":
|
case "provisionedBy":
|
||||||
@@ -8537,8 +8539,8 @@ func (ec *executionContext) fieldContext_OrganizationSessionCreated_membership(_
|
|||||||
return ec.fieldContext_Membership_active(ctx, field)
|
return ec.fieldContext_Membership_active(ctx, field)
|
||||||
case "lastSyncedAt":
|
case "lastSyncedAt":
|
||||||
return ec.fieldContext_Membership_lastSyncedAt(ctx, field)
|
return ec.fieldContext_Membership_lastSyncedAt(ctx, field)
|
||||||
case "activeSession":
|
case "lastSession":
|
||||||
return ec.fieldContext_Membership_activeSession(ctx, field)
|
return ec.fieldContext_Membership_lastSession(ctx, field)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("no field named %q was found under type Membership", field.Name)
|
return nil, fmt.Errorf("no field named %q was found under type Membership", field.Name)
|
||||||
},
|
},
|
||||||
@@ -15884,7 +15886,7 @@ func (ec *executionContext) _Membership(ctx context.Context, sel ast.SelectionSe
|
|||||||
}
|
}
|
||||||
case "lastSyncedAt":
|
case "lastSyncedAt":
|
||||||
out.Values[i] = ec._Membership_lastSyncedAt(ctx, field, obj)
|
out.Values[i] = ec._Membership_lastSyncedAt(ctx, field, obj)
|
||||||
case "activeSession":
|
case "lastSession":
|
||||||
field := field
|
field := field
|
||||||
|
|
||||||
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
|
innerFunc := func(ctx context.Context, _ *graphql.FieldSet) (res graphql.Marshaler) {
|
||||||
@@ -15893,7 +15895,7 @@ func (ec *executionContext) _Membership(ctx context.Context, sel ast.SelectionSe
|
|||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
ec.Error(ctx, ec.Recover(ctx, r))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
res = ec._Membership_activeSession(ctx, field, obj)
|
res = ec._Membership_lastSession(ctx, field, obj)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ type Membership struct {
|
|||||||
ProvisionedBy ProvisioningSource `json:"provisionedBy"`
|
ProvisionedBy ProvisioningSource `json:"provisionedBy"`
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
LastSyncedAt *time.Time `json:"lastSyncedAt,omitempty"`
|
LastSyncedAt *time.Time `json:"lastSyncedAt,omitempty"`
|
||||||
ActiveSession *Session `json:"activeSession,omitempty"`
|
LastSession *Session `json:"lastSession,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Membership) IsNode() {}
|
func (Membership) IsNode() {}
|
||||||
|
|||||||
@@ -154,25 +154,17 @@ func (r *membershipResolver) Organization(ctx context.Context, obj *types.Member
|
|||||||
return types.NewOrganization(organization), nil
|
return types.NewOrganization(organization), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActiveSession is the resolver for the activeSession field.
|
// LastSession is the resolver for the lastSession field.
|
||||||
func (r *membershipResolver) ActiveSession(ctx context.Context, obj *types.Membership) (*types.Session, error) {
|
func (r *membershipResolver) LastSession(ctx context.Context, obj *types.Membership) (*types.Session, error) {
|
||||||
rootSession := SessionFromContext(ctx)
|
session := SessionFromContext(ctx)
|
||||||
|
|
||||||
session, err := r.iam.SessionService.GetActiveSessionForMembership(ctx, rootSession.UserID, obj.ID)
|
childSession, err := r.iam.SessionService.GetActiveSessionForMembership(ctx, session.ID, obj.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var (
|
panic(fmt.Errorf("cannot get active session for membership: %w", err))
|
||||||
errSessionNotFound *iam.ErrSessionNotFound
|
|
||||||
errSessionExpired *iam.ErrSessionExpired
|
|
||||||
)
|
|
||||||
|
|
||||||
if errors.As(err, &errSessionNotFound) || errors.As(err, &errSessionExpired) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
panic(fmt.Errorf("cannot get active session: %w", err))
|
return types.NewSession(childSession), nil
|
||||||
}
|
|
||||||
|
|
||||||
return types.NewSession(session), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TotalCount is the resolver for the totalCount field.
|
// TotalCount is the resolver for the totalCount field.
|
||||||
@@ -1100,15 +1092,3 @@ type personalAPIKeyConnectionResolver struct{ *Resolver }
|
|||||||
type queryResolver struct{ *Resolver }
|
type queryResolver struct{ *Resolver }
|
||||||
type sAMLConfigurationConnectionResolver struct{ *Resolver }
|
type sAMLConfigurationConnectionResolver struct{ *Resolver }
|
||||||
type sessionConnectionResolver struct{ *Resolver }
|
type sessionConnectionResolver struct{ *Resolver }
|
||||||
|
|
||||||
// !!! WARNING !!!
|
|
||||||
// The code below was going to be deleted when updating resolvers. It has been copied here so you have
|
|
||||||
// one last chance to move it out of harms way if you want. There are two reasons this happens:
|
|
||||||
// - When renaming or deleting a resolver the old code will be put in here. You can safely delete
|
|
||||||
// it when you're done.
|
|
||||||
// - You have helper methods in this file. Move them out to keep these resolver files clean.
|
|
||||||
/*
|
|
||||||
func (r *mutationResolver) SignInWithSession(ctx context.Context, input types.SignInWithSessionInput) (*types.SignInWithSessionPayload, error) {
|
|
||||||
panic(fmt.Errorf("not implemented: SignInWithSession - signInWithSession"))
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|||||||
Reference in New Issue
Block a user