Add fields to organization

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-09-19 16:05:07 +02:00
parent b39dd79728
commit 104330d3fd
17 changed files with 971 additions and 96 deletions

View File

@@ -37,6 +37,11 @@ type Organization implements Node {
id: ID!
name: String!
logoUrl: String @goField(forceResolver: true)
description: String
websiteUrl: String
email: String
headquarterAddress: String
}
enum DocumentType

View File

@@ -117,9 +117,13 @@ type ComplexityRoot struct {
}
Organization struct {
ID func(childComplexity int) int
LogoURL func(childComplexity int) int
Name func(childComplexity int) int
Description func(childComplexity int) int
Email func(childComplexity int) int
HeadquarterAddress func(childComplexity int) int
ID func(childComplexity int) int
LogoURL func(childComplexity int) int
Name func(childComplexity int) int
WebsiteURL func(childComplexity int) int
}
PageInfo struct {
@@ -413,6 +417,27 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
return e.complexity.Mutation.ExportReportPDF(childComplexity, args["input"].(types.ExportReportPDFInput)), true
case "Organization.description":
if e.complexity.Organization.Description == nil {
break
}
return e.complexity.Organization.Description(childComplexity), true
case "Organization.email":
if e.complexity.Organization.Email == nil {
break
}
return e.complexity.Organization.Email(childComplexity), true
case "Organization.headquarterAddress":
if e.complexity.Organization.HeadquarterAddress == nil {
break
}
return e.complexity.Organization.HeadquarterAddress(childComplexity), true
case "Organization.id":
if e.complexity.Organization.ID == nil {
break
@@ -434,6 +459,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin
return e.complexity.Organization.Name(childComplexity), true
case "Organization.websiteUrl":
if e.complexity.Organization.WebsiteURL == nil {
break
}
return e.complexity.Organization.WebsiteURL(childComplexity), true
case "PageInfo.endCursor":
if e.complexity.PageInfo.EndCursor == nil {
break
@@ -833,6 +865,11 @@ type Organization implements Node {
id: ID!
name: String!
logoUrl: String @goField(forceResolver: true)
description: String
websiteUrl: String
email: String
headquarterAddress: String
}
enum DocumentType
@@ -3265,6 +3302,170 @@ func (ec *executionContext) fieldContext_Organization_logoUrl(_ context.Context,
return fc, nil
}
func (ec *executionContext) _Organization_description(ctx context.Context, field graphql.CollectedField, obj *types.Organization) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Organization_description(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.Description, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*string)
fc.Result = res
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Organization_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Organization",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Organization_websiteUrl(ctx context.Context, field graphql.CollectedField, obj *types.Organization) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Organization_websiteUrl(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.WebsiteURL, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*string)
fc.Result = res
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Organization_websiteUrl(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Organization",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Organization_email(ctx context.Context, field graphql.CollectedField, obj *types.Organization) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Organization_email(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.Email, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*string)
fc.Result = res
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Organization_email(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Organization",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _Organization_headquarterAddress(ctx context.Context, field graphql.CollectedField, obj *types.Organization) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Organization_headquarterAddress(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
ctx = rctx // use context from middleware stack in children
return obj.HeadquarterAddress, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*string)
fc.Result = res
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Organization_headquarterAddress(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Organization",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type String does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *types.PageInfo) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field)
if err != nil {
@@ -4016,6 +4217,14 @@ func (ec *executionContext) fieldContext_TrustCenter_organization(_ context.Cont
return ec.fieldContext_Organization_name(ctx, field)
case "logoUrl":
return ec.fieldContext_Organization_logoUrl(ctx, field)
case "description":
return ec.fieldContext_Organization_description(ctx, field)
case "websiteUrl":
return ec.fieldContext_Organization_websiteUrl(ctx, field)
case "email":
return ec.fieldContext_Organization_email(ctx, field)
case "headquarterAddress":
return ec.fieldContext_Organization_headquarterAddress(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type Organization", field.Name)
},
@@ -7781,6 +7990,14 @@ func (ec *executionContext) _Organization(ctx context.Context, sel ast.Selection
}
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
case "description":
out.Values[i] = ec._Organization_description(ctx, field, obj)
case "websiteUrl":
out.Values[i] = ec._Organization_websiteUrl(ctx, field, obj)
case "email":
out.Values[i] = ec._Organization_email(ctx, field, obj)
case "headquarterAddress":
out.Values[i] = ec._Organization_headquarterAddress(ctx, field, obj)
default:
panic("unknown field " + strconv.Quote(field.Name))
}

View File

@@ -20,7 +20,11 @@ import (
func NewOrganization(o *coredata.Organization) *Organization {
return &Organization{
ID: o.ID,
Name: o.Name,
ID: o.ID,
Name: o.Name,
Description: o.Description,
WebsiteURL: o.WebsiteURL,
Email: o.Email,
HeadquarterAddress: o.HeadquarterAddress,
}
}

View File

@@ -103,9 +103,13 @@ type Mutation struct {
}
type Organization struct {
ID gid.GID `json:"id"`
Name string `json:"name"`
LogoURL *string `json:"logoUrl,omitempty"`
ID gid.GID `json:"id"`
Name string `json:"name"`
LogoURL *string `json:"logoUrl,omitempty"`
Description *string `json:"description,omitempty"`
WebsiteURL *string `json:"websiteUrl,omitempty"`
Email *string `json:"email,omitempty"`
HeadquarterAddress *string `json:"headquarterAddress,omitempty"`
}
func (Organization) IsNode() {}