From 893de4f5c0e852fac9a73e0c0243bc038af75f17 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 25 Feb 2020 21:35:57 +0100 Subject: identity: bring back the login to hold that info from bridges (purely informational) --- graphql/graph/gen_graph.go | 43 +++++++++++++++++++++++++++++++++++++++++ graphql/models/lazy_identity.go | 13 +++++++++++++ graphql/schema/identity.graphql | 2 ++ 3 files changed, 58 insertions(+) (limited to 'graphql') diff --git a/graphql/graph/gen_graph.go b/graphql/graph/gen_graph.go index 5c84dae1..277cb7cb 100644 --- a/graphql/graph/gen_graph.go +++ b/graphql/graph/gen_graph.go @@ -200,6 +200,7 @@ type ComplexityRoot struct { HumanID func(childComplexity int) int ID func(childComplexity int) int IsProtected func(childComplexity int) int + Login func(childComplexity int) int Name func(childComplexity int) int } @@ -1100,6 +1101,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Identity.IsProtected(childComplexity), true + case "Identity.login": + if e.complexity.Identity.Login == nil { + break + } + + return e.complexity.Identity.Login(childComplexity), true + case "Identity.name": if e.complexity.Identity.Name == nil { break @@ -1941,6 +1949,8 @@ type Identity { name: String """The email of the person, if known.""" email: String + """The login of the person, if known.""" + login: String """A non-empty string to display, representing the identity, based on the non-empty values.""" displayName: String! """An url to an avatar""" @@ -5711,6 +5721,37 @@ func (ec *executionContext) _Identity_email(ctx context.Context, field graphql.C return ec.marshalOString2string(ctx, field.Selections, res) } +func (ec *executionContext) _Identity_login(ctx context.Context, field graphql.CollectedField, obj models.IdentityWrapper) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Identity", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Login() + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + func (ec *executionContext) _Identity_displayName(ctx context.Context, field graphql.CollectedField, obj models.IdentityWrapper) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -11256,6 +11297,8 @@ func (ec *executionContext) _Identity(ctx context.Context, sel ast.SelectionSet, out.Values[i] = ec._Identity_name(ctx, field, obj) case "email": out.Values[i] = ec._Identity_email(ctx, field, obj) + case "login": + out.Values[i] = ec._Identity_login(ctx, field, obj) case "displayName": out.Values[i] = ec._Identity_displayName(ctx, field, obj) if out.Values[i] == graphql.Null { diff --git a/graphql/models/lazy_identity.go b/graphql/models/lazy_identity.go index bbd36be3..344bb5f0 100644 --- a/graphql/models/lazy_identity.go +++ b/graphql/models/lazy_identity.go @@ -18,6 +18,7 @@ type IdentityWrapper interface { Id() entity.Id Name() string Email() (string, error) + Login() (string, error) AvatarUrl() (string, error) Keys() ([]*identity.Key, error) ValidKeysAtTime(time lamport.Time) ([]*identity.Key, error) @@ -76,6 +77,14 @@ func (li *lazyIdentity) Email() (string, error) { return id.Email(), nil } +func (li *lazyIdentity) Login() (string, error) { + id, err := li.load() + if err != nil { + return "", err + } + return id.Login(), nil +} + func (li *lazyIdentity) AvatarUrl() (string, error) { id, err := li.load() if err != nil { @@ -142,6 +151,10 @@ func (l loadedIdentity) Email() (string, error) { return l.Interface.Email(), nil } +func (l loadedIdentity) Login() (string, error) { + return l.Interface.Login(), nil +} + func (l loadedIdentity) AvatarUrl() (string, error) { return l.Interface.AvatarUrl(), nil } diff --git a/graphql/schema/identity.graphql b/graphql/schema/identity.graphql index 6490d538..93154a90 100644 --- a/graphql/schema/identity.graphql +++ b/graphql/schema/identity.graphql @@ -8,6 +8,8 @@ type Identity { name: String """The email of the person, if known.""" email: String + """The login of the person, if known.""" + login: String """A non-empty string to display, representing the identity, based on the non-empty values.""" displayName: String! """An url to an avatar""" -- cgit