~comcloudway/builds.sr.ht

45812de33ac341c4ffd4e0530e1aa6c7e4fe8a85 — Drew DeVault 1 year, 1 month ago 663ad82
api: fix fromUser implementation issues
3 files changed, 20 insertions(+), 11 deletions(-)

M api/graph/model/secrets.go
M api/graph/schema.graphqls
M api/graph/schema.resolvers.go
M api/graph/model/secrets.go => api/graph/model/secrets.go +4 -4
@@ 32,7 32,7 @@ type RawSecret struct {
	Path       *string
	Mode       *int

	FromUserID int
	FromUserID *int

	alias  string
	fields *database.ModelFields


@@ 58,7 58,7 @@ type PGPKey struct {
	Name       *string   `json:"name"`
	PrivateKey []byte    `json:"privateKey"`

	FromUserID int
	FromUserID *int
}

func (PGPKey) IsSecret() {}


@@ 70,7 70,7 @@ type SSHKey struct {
	Name       *string   `json:"name"`
	PrivateKey []byte    `json:"privateKey"`

	FromUserID int
	FromUserID *int
}

func (SSHKey) IsSecret() {}


@@ 84,7 84,7 @@ type SecretFile struct {
	Mode    int       `json:"mode"`
	Data    []byte    `json:"data"`

	FromUserID int
	FromUserID *int
}

func (SecretFile) IsSecret() {}

M api/graph/schema.graphqls => api/graph/schema.graphqls +4 -4
@@ 233,7 233,7 @@ interface Secret {
  uuid: String!
  name: String
  "Set when this secret was copied from another user account"
  from_user: Entity
  fromUser: Entity
}

"""


@@ 253,7 253,7 @@ type SSHKey implements Secret {
  created: Time!
  uuid: String!
  name: String
  from_user: Entity
  fromUser: Entity
  privateKey: Binary! @worker
}



@@ 262,7 262,7 @@ type PGPKey implements Secret {
  created: Time!
  uuid: String!
  name: String
  from_user: Entity
  fromUser: Entity
  privateKey: Binary! @worker
}



@@ 271,7 271,7 @@ type SecretFile implements Secret {
  created: Time!
  uuid: String!
  name: String
  from_user: Entity
  fromUser: Entity
  path: String!
  mode: Int!
  data: Binary! @worker

M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +12 -3
@@ 817,7 817,10 @@ func (r *mutationResolver) DeleteUser(ctx context.Context) (int, error) {

// FromUser is the resolver for the from_user field.
func (r *pGPKeyResolver) FromUser(ctx context.Context, obj *model.PGPKey) (model.Entity, error) {
	return loaders.ForContext(ctx).UsersByID.Load(obj.FromUserID)
	if obj.FromUserID == nil {
		return nil, nil
	}
	return loaders.ForContext(ctx).UsersByID.Load(*obj.FromUserID)
}

// PrivateKey is the resolver for the privateKey field.


@@ 1005,7 1008,10 @@ func (r *queryResolver) Webhook(ctx context.Context) (model.WebhookPayload, erro

// FromUser is the resolver for the from_user field.
func (r *sSHKeyResolver) FromUser(ctx context.Context, obj *model.SSHKey) (model.Entity, error) {
	return loaders.ForContext(ctx).UsersByID.Load(obj.FromUserID)
	if obj.FromUserID == nil {
		return nil, nil
	}
	return loaders.ForContext(ctx).UsersByID.Load(*obj.FromUserID)
}

// PrivateKey is the resolver for the privateKey field.


@@ 1017,7 1023,10 @@ func (r *sSHKeyResolver) PrivateKey(ctx context.Context, obj *model.SSHKey) (str

// FromUser is the resolver for the from_user field.
func (r *secretFileResolver) FromUser(ctx context.Context, obj *model.SecretFile) (model.Entity, error) {
	return loaders.ForContext(ctx).UsersByID.Load(obj.FromUserID)
	if obj.FromUserID == nil {
		return nil, nil
	}
	return loaders.ForContext(ctx).UsersByID.Load(*obj.FromUserID)
}

// Data is the resolver for the data field.