~edwargix/git.sr.ht

daab41b1e9d4cba0b2b42057439337d8de432475 — Drew DeVault 5 years ago 035b31b
api: rig up repository { objects(id...) }
3 files changed, 39 insertions(+), 30 deletions(-)

M api/graph/generated/generated.go
M api/graph/schema.graphqls
M api/graph/schema.resolvers.go
M api/graph/generated/generated.go => api/graph/generated/generated.go +25 -25
@@ 138,7 138,7 @@ type ComplexityRoot struct {
		ID                func(childComplexity int) int
		Log               func(childComplexity int, cursor *model.Cursor, from *string) int
		Name              func(childComplexity int) int
		Objects           func(childComplexity int, ids []*string) int
		Objects           func(childComplexity int, ids []string) int
		Owner             func(childComplexity int) int
		Path              func(childComplexity int, revspec *string, path string) int
		References        func(childComplexity int, cursor *model.Cursor) int


@@ 249,8 249,8 @@ type RepositoryResolver interface {
	Owner(ctx context.Context, obj *model.Repository) (model.Entity, error)

	AccessControlList(ctx context.Context, obj *model.Repository, cursor *model.Cursor) (*model.ACLCursor, error)
	Objects(ctx context.Context, obj *model.Repository, ids []string) ([]model.Object, error)
	References(ctx context.Context, obj *model.Repository, cursor *model.Cursor) (*model.ReferenceCursor, error)
	Objects(ctx context.Context, obj *model.Repository, ids []*string) ([]model.Object, error)

	Log(ctx context.Context, obj *model.Repository, cursor *model.Cursor, from *string) (*model.CommitCursor, error)
	Path(ctx context.Context, obj *model.Repository, revspec *string, path string) (*model.TreeEntry, error)


@@ 757,7 757,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
			return 0, false
		}

		return e.complexity.Repository.Objects(childComplexity, args["ids"].([]*string)), true
		return e.complexity.Repository.Objects(childComplexity, args["ids"].([]string)), true

	case "Repository.owner":
		if e.complexity.Repository.Owner == nil {


@@ 1283,8 1283,8 @@ type Repository {

  ## Plumbing API:

  objects(ids: [String!]): [Object]!
  references(cursor: Cursor): ReferenceCursor!
  objects(ids: [String]): [Object]!

  ## Porcelain API:



@@ 1820,9 1820,9 @@ func (ec *executionContext) field_Repository_log_args(ctx context.Context, rawAr
func (ec *executionContext) field_Repository_objects_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
	var err error
	args := map[string]interface{}{}
	var arg0 []*string
	var arg0 []string
	if tmp, ok := rawArgs["ids"]; ok {
		arg0, err = ec.unmarshalOString2ᚕᚖstring(ctx, tmp)
		arg0, err = ec.unmarshalOString2ᚕstringᚄ(ctx, tmp)
		if err != nil {
			return nil, err
		}


@@ 4097,7 4097,7 @@ func (ec *executionContext) _Repository_accessControlList(ctx context.Context, f
	return ec.marshalNACLCursor2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋgitᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐACLCursor(ctx, field.Selections, res)
}

func (ec *executionContext) _Repository_references(ctx context.Context, field graphql.CollectedField, obj *model.Repository) (ret graphql.Marshaler) {
func (ec *executionContext) _Repository_objects(ctx context.Context, field graphql.CollectedField, obj *model.Repository) (ret graphql.Marshaler) {
	defer func() {
		if r := recover(); r != nil {
			ec.Error(ctx, ec.Recover(ctx, r))


@@ 4113,7 4113,7 @@ func (ec *executionContext) _Repository_references(ctx context.Context, field gr

	ctx = graphql.WithFieldContext(ctx, fc)
	rawArgs := field.ArgumentMap(ec.Variables)
	args, err := ec.field_Repository_references_args(ctx, rawArgs)
	args, err := ec.field_Repository_objects_args(ctx, rawArgs)
	if err != nil {
		ec.Error(ctx, err)
		return graphql.Null


@@ 4121,7 4121,7 @@ func (ec *executionContext) _Repository_references(ctx context.Context, field gr
	fc.Args = args
	resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
		ctx = rctx // use context from middleware stack in children
		return ec.resolvers.Repository().References(rctx, obj, args["cursor"].(*model.Cursor))
		return ec.resolvers.Repository().Objects(rctx, obj, args["ids"].([]string))
	})
	if err != nil {
		ec.Error(ctx, err)


@@ 4133,12 4133,12 @@ func (ec *executionContext) _Repository_references(ctx context.Context, field gr
		}
		return graphql.Null
	}
	res := resTmp.(*model.ReferenceCursor)
	res := resTmp.([]model.Object)
	fc.Result = res
	return ec.marshalNReferenceCursor2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋgitᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐReferenceCursor(ctx, field.Selections, res)
	return ec.marshalNObject2ᚕgitᚗsrᚗhtᚋאsircmpwnᚋgitᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐObject(ctx, field.Selections, res)
}

func (ec *executionContext) _Repository_objects(ctx context.Context, field graphql.CollectedField, obj *model.Repository) (ret graphql.Marshaler) {
func (ec *executionContext) _Repository_references(ctx context.Context, field graphql.CollectedField, obj *model.Repository) (ret graphql.Marshaler) {
	defer func() {
		if r := recover(); r != nil {
			ec.Error(ctx, ec.Recover(ctx, r))


@@ 4154,7 4154,7 @@ func (ec *executionContext) _Repository_objects(ctx context.Context, field graph

	ctx = graphql.WithFieldContext(ctx, fc)
	rawArgs := field.ArgumentMap(ec.Variables)
	args, err := ec.field_Repository_objects_args(ctx, rawArgs)
	args, err := ec.field_Repository_references_args(ctx, rawArgs)
	if err != nil {
		ec.Error(ctx, err)
		return graphql.Null


@@ 4162,7 4162,7 @@ func (ec *executionContext) _Repository_objects(ctx context.Context, field graph
	fc.Args = args
	resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
		ctx = rctx // use context from middleware stack in children
		return ec.resolvers.Repository().Objects(rctx, obj, args["ids"].([]*string))
		return ec.resolvers.Repository().References(rctx, obj, args["cursor"].(*model.Cursor))
	})
	if err != nil {
		ec.Error(ctx, err)


@@ 4174,9 4174,9 @@ func (ec *executionContext) _Repository_objects(ctx context.Context, field graph
		}
		return graphql.Null
	}
	res := resTmp.([]model.Object)
	res := resTmp.(*model.ReferenceCursor)
	fc.Result = res
	return ec.marshalNObject2ᚕgitᚗsrᚗhtᚋאsircmpwnᚋgitᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐObject(ctx, field.Selections, res)
	return ec.marshalNReferenceCursor2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋgitᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐReferenceCursor(ctx, field.Selections, res)
}

func (ec *executionContext) _Repository_HEAD(ctx context.Context, field graphql.CollectedField, obj *model.Repository) (ret graphql.Marshaler) {


@@ 7634,7 7634,7 @@ func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSe
				}
				return res
			})
		case "references":
		case "objects":
			field := field
			out.Concurrently(i, func() (res graphql.Marshaler) {
				defer func() {


@@ 7642,13 7642,13 @@ func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSe
						ec.Error(ctx, ec.Recover(ctx, r))
					}
				}()
				res = ec._Repository_references(ctx, field, obj)
				res = ec._Repository_objects(ctx, field, obj)
				if res == graphql.Null {
					atomic.AddUint32(&invalids, 1)
				}
				return res
			})
		case "objects":
		case "references":
			field := field
			out.Concurrently(i, func() (res graphql.Marshaler) {
				defer func() {


@@ 7656,7 7656,7 @@ func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSe
						ec.Error(ctx, ec.Recover(ctx, r))
					}
				}()
				res = ec._Repository_objects(ctx, field, obj)
				res = ec._Repository_references(ctx, field, obj)
				if res == graphql.Null {
					atomic.AddUint32(&invalids, 1)
				}


@@ 9354,7 9354,7 @@ func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.S
	return graphql.MarshalString(v)
}

func (ec *executionContext) unmarshalOString2ᚕᚖstring(ctx context.Context, v interface{}) ([]*string, error) {
func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) {
	var vSlice []interface{}
	if v != nil {
		if tmp1, ok := v.([]interface{}); ok {


@@ 9364,9 9364,9 @@ func (ec *executionContext) unmarshalOString2ᚕᚖstring(ctx context.Context, v
		}
	}
	var err error
	res := make([]*string, len(vSlice))
	res := make([]string, len(vSlice))
	for i := range vSlice {
		res[i], err = ec.unmarshalOString2ᚖstring(ctx, vSlice[i])
		res[i], err = ec.unmarshalNString2string(ctx, vSlice[i])
		if err != nil {
			return nil, err
		}


@@ 9374,13 9374,13 @@ func (ec *executionContext) unmarshalOString2ᚕᚖstring(ctx context.Context, v
	return res, nil
}

func (ec *executionContext) marshalOString2ᚕᚖstring(ctx context.Context, sel ast.SelectionSet, v []*string) graphql.Marshaler {
func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler {
	if v == nil {
		return graphql.Null
	}
	ret := make(graphql.Array, len(v))
	for i := range v {
		ret[i] = ec.marshalOString2ᚖstring(ctx, sel, v[i])
		ret[i] = ec.marshalNString2string(ctx, sel, v[i])
	}

	return ret

M api/graph/schema.graphqls => api/graph/schema.graphqls +1 -1
@@ 71,8 71,8 @@ type Repository {

  ## Plumbing API:

  objects(ids: [String!]): [Object]!
  references(cursor: Cursor): ReferenceCursor!
  objects(ids: [String]): [Object]!

  ## Porcelain API:


M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +13 -4
@@ 168,6 168,19 @@ func (r *repositoryResolver) AccessControlList(ctx context.Context, obj *model.R
	return &model.ACLCursor{acls, cursor}, nil
}

func (r *repositoryResolver) Objects(ctx context.Context, obj *model.Repository, ids []string) ([]model.Object, error) {
	var objects []model.Object
	for _, id := range ids {
		hash := plumbing.NewHash(id)
		o, err := model.LookupObject(obj.Repo(), hash)
		if err != nil {
			return nil, err
		}
		objects = append(objects, o)
	}
	return objects, nil
}

func (r *repositoryResolver) References(ctx context.Context, obj *model.Repository, cursor *model.Cursor) (*model.ReferenceCursor, error) {
	iter, err := obj.Repo().References()
	if err != nil {


@@ 214,10 227,6 @@ func (r *repositoryResolver) References(ctx context.Context, obj *model.Reposito
	return &model.ReferenceCursor{refs, cursor}, nil
}

func (r *repositoryResolver) Objects(ctx context.Context, obj *model.Repository, ids []*string) ([]model.Object, error) {
	panic(fmt.Errorf("not implemented"))
}

func (r *repositoryResolver) Log(ctx context.Context, obj *model.Repository, cursor *model.Cursor, from *string) (*model.CommitCursor, error) {
	if cursor == nil {
		cursor = model.NewCursor(nil)