From 61ee8c3f834114cfa305ef8a13890a4218919ab6 Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Wed, 13 Mar 2024 07:30:23 -0600 Subject: [PATCH] Working to resolve graphql perm issues for non auth users. --- api/graph/generated.go | 106 +++++++++++++++++----------------- api/graph/schema.graphqls | 18 +++--- api/graph/schema.resolvers.go | 2 +- go.sum | 2 - list/routes.go | 2 - 5 files changed, 63 insertions(+), 67 deletions(-) diff --git a/api/graph/generated.go b/api/graph/generated.go index ce03fc5..01e9e3e 100644 --- a/api/graph/generated.go +++ b/api/graph/generated.go @@ -4727,10 +4727,10 @@ func (ec *executionContext) _BaseURL_publicReady(ctx context.Context, field grap return obj.PublicReady, nil } directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.Private == nil { - return nil, errors.New("directive private is not implemented") + if ec.directives.Internal == nil { + return nil, errors.New("directive internal is not implemented") } - return ec.directives.Private(ctx, obj, directive0) + return ec.directives.Internal(ctx, obj, directive0) } tmp, err := directive1(rctx) @@ -4786,28 +4786,8 @@ func (ec *executionContext) _BaseURL_data(ctx context.Context, field graphql.Col } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Data, nil - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.Private == nil { - return nil, errors.New("directive private is not implemented") - } - return ec.directives.Private(ctx, obj, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(models.BaseURLData); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be links/models.BaseURLData`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Data, nil }) if err != nil { ec.Error(ctx, err) @@ -7095,8 +7075,28 @@ func (ec *executionContext) _Listing_isActive(ctx context.Context, field graphql } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsActive, nil + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsActive, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.Private == nil { + return nil, errors.New("directive private is not implemented") + } + return ec.directives.Private(ctx, obj, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -7139,8 +7139,28 @@ func (ec *executionContext) _Listing_isDefault(ctx context.Context, field graphq } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsDefault, nil + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDefault, nil + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.Private == nil { + return nil, errors.New("directive private is not implemented") + } + return ec.directives.Private(ctx, obj, directive0) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -7242,7 +7262,7 @@ func (ec *executionContext) _Listing_userId(ctx context.Context, field graphql.C return obj.UserID, nil } directive1 := func(ctx context.Context) (interface{}, error) { - scope, err := ec.unmarshalNAccessScope2linksᚋapiᚋgraphᚋmodelᚐAccessScope(ctx, "SHORTS") + scope, err := ec.unmarshalNAccessScope2linksᚋapiᚋgraphᚋmodelᚐAccessScope(ctx, "LISTS") if err != nil { return nil, err } @@ -7974,7 +7994,7 @@ func (ec *executionContext) _ListingLink_userId(ctx context.Context, field graph return obj.UserID, nil } directive1 := func(ctx context.Context) (interface{}, error) { - scope, err := ec.unmarshalNAccessScope2linksᚋapiᚋgraphᚋmodelᚐAccessScope(ctx, "SHORTS") + scope, err := ec.unmarshalNAccessScope2linksᚋapiᚋgraphᚋmodelᚐAccessScope(ctx, "LISTS") if err != nil { return nil, err } @@ -8041,28 +8061,8 @@ func (ec *executionContext) _ListingLink_listingId(ctx context.Context, field gr } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ListingID, nil - } - directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.Private == nil { - return nil, errors.New("directive private is not implemented") - } - return ec.directives.Private(ctx, obj, directive0) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(int); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be int`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.ListingID, nil }) if err != nil { ec.Error(ctx, err) diff --git a/api/graph/schema.graphqls b/api/graph/schema.graphqls index 32f7ff2..b7eacc9 100644 --- a/api/graph/schema.graphqls +++ b/api/graph/schema.graphqls @@ -126,8 +126,8 @@ type BaseURL { url: String! counter: Int! tags: [Tag]! - publicReady: Boolean! @private - data: BaseURLData! @private + publicReady: Boolean! @internal + data: BaseURLData! createdOn: Time! @private updatedOn: Time! @private } @@ -170,8 +170,8 @@ type LinkShort { domainId: Int @private orgId: Int! lookupName: String! @private - createdOn: Time !@private - updatedOn: Time !@private + createdOn: Time! @private + updatedOn: Time! @private } type Metadata { @@ -192,10 +192,10 @@ type Listing { slug: String! image: String! metadata: Metadata! - isActive: Boolean! - isDefault: Boolean! + isActive: Boolean! @private + isDefault: Boolean! @private tags: [Tag]! - userId: Int! @access(scope: SHORTS, kind: RO) + userId: Int! @access(scope: LISTS, kind: RO) orgId: Int! @private domainId: Int! @private lookupName: String! @private @@ -209,8 +209,8 @@ type ListingLink { linkOrder: Int! url: String! description: String - userId: Int! @access(scope: SHORTS, kind: RO) - listingId: Int! @private + userId: Int! @access(scope: LISTS, kind: RO) + listingId: Int! clicks: Int! @private createdOn: Time! @private updatedOn: Time! @private diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go index 903d61e..0e1fc87 100644 --- a/api/graph/schema.resolvers.go +++ b/api/graph/schema.resolvers.go @@ -39,7 +39,7 @@ import ( "golang.org/x/image/draw" "golang.org/x/net/idna" "netlandish.com/x/gobwebs" - oauth2 "netlandish.com/x/gobwebs-oauth2" + "netlandish.com/x/gobwebs-oauth2" gaccounts "netlandish.com/x/gobwebs/accounts" "netlandish.com/x/gobwebs/database" "netlandish.com/x/gobwebs/email" diff --git a/go.sum b/go.sum index 26175c4..d875030 100644 --- a/go.sum +++ b/go.sum @@ -2556,8 +2556,6 @@ modernc.org/z v1.0.1-0.20210308123920-1f282aa71362/go.mod h1:8/SRk5C/HgiQWCgXdfp modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA= modernc.org/z v1.2.20/go.mod h1:zU9FiF4PbHdOTUxw+IF8j7ArBMRPsHgq10uVPt6xTzo= modernc.org/zappy v1.0.0/go.mod h1:hHe+oGahLVII/aTTyWK/b53VDHMAGCBYYeZ9sn83HC4= -netlandish.com/x/gobwebs v0.0.0-20240308002929-df98b40506b0 h1:gFEdXLA+VFvSoxV+ps80q0Ergyb9l3R/4xj6Evy9z1I= -netlandish.com/x/gobwebs v0.0.0-20240308002929-df98b40506b0/go.mod h1:77W9AvqBop739PH+KmyU7DpNpbM9f4iE8qyXj7GcNyE= netlandish.com/x/gobwebs v0.0.0-20240309201308-582da32e3e94 h1:AaAvUOHYDgkLKwnX+Owtw4sXmYduL6/1jm5Vz20CWFM= netlandish.com/x/gobwebs v0.0.0-20240309201308-582da32e3e94/go.mod h1:77W9AvqBop739PH+KmyU7DpNpbM9f4iE8qyXj7GcNyE= netlandish.com/x/gobwebs-formguard v0.0.0-20231224192353-29706d23f156 h1:kbYL/3PDS6Pt5uE5QJWkVIgd+kzUgUUb3IKhAth35Bc= diff --git a/list/routes.go b/list/routes.go index 36daacb..0b6881a 100644 --- a/list/routes.go +++ b/list/routes.go @@ -1542,8 +1542,6 @@ func (r *DetailService) ListDetail(c echo.Context) error { url description linkOrder - createdOn - updatedOn } pageInfo { cursor -- 2.43.0