add a new query - similarQualifications
This commit is contained in:
parent
0b14efd014
commit
44ca74144f
2
go.mod
2
go.mod
|
@ -19,7 +19,7 @@ require (
|
|||
github.com/sirupsen/logrus v1.8.0
|
||||
github.com/vektah/gqlparser/v2 v2.1.0
|
||||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect
|
||||
golang.org/x/sys v0.0.0-20210326220804-49726bf1d181 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
|
4
go.sum
4
go.sum
|
@ -223,8 +223,8 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210218155724-8ebf48af031b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210326220804-49726bf1d181 h1:64ChN/hjER/taL4YJuA+gpLfIMT+/NFherRZixbxOhg=
|
||||
golang.org/x/sys v0.0.0-20210326220804-49726bf1d181/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
|
|
|
@ -96,15 +96,16 @@ type ComplexityRoot struct {
|
|||
}
|
||||
|
||||
Query struct {
|
||||
GenerateTest func(childComplexity int, qualificationIDs []int, limit *int) int
|
||||
Me func(childComplexity int) int
|
||||
Profession func(childComplexity int, id *int, slug *string) int
|
||||
Professions func(childComplexity int, filter *models.ProfessionFilter, limit *int, offset *int, sort []string) int
|
||||
Qualification func(childComplexity int, id *int, slug *string) int
|
||||
Qualifications func(childComplexity int, filter *models.QualificationFilter, limit *int, offset *int, sort []string) int
|
||||
Questions func(childComplexity int, filter *models.QuestionFilter, limit *int, offset *int, sort []string) int
|
||||
User func(childComplexity int, id int) int
|
||||
Users func(childComplexity int, filter *models.UserFilter, limit *int, offset *int, sort []string) int
|
||||
GenerateTest func(childComplexity int, qualificationIDs []int, limit *int) int
|
||||
Me func(childComplexity int) int
|
||||
Profession func(childComplexity int, id *int, slug *string) int
|
||||
Professions func(childComplexity int, filter *models.ProfessionFilter, limit *int, offset *int, sort []string) int
|
||||
Qualification func(childComplexity int, id *int, slug *string) int
|
||||
Qualifications func(childComplexity int, filter *models.QualificationFilter, limit *int, offset *int, sort []string) int
|
||||
Questions func(childComplexity int, filter *models.QuestionFilter, limit *int, offset *int, sort []string) int
|
||||
SimilarQualifications func(childComplexity int, qualificationID int, limit *int, offset *int, sort []string) int
|
||||
User func(childComplexity int, id int) int
|
||||
Users func(childComplexity int, filter *models.UserFilter, limit *int, offset *int, sort []string) int
|
||||
}
|
||||
|
||||
Question struct {
|
||||
|
@ -175,6 +176,7 @@ type QueryResolver interface {
|
|||
Professions(ctx context.Context, filter *models.ProfessionFilter, limit *int, offset *int, sort []string) (*ProfessionList, error)
|
||||
Profession(ctx context.Context, id *int, slug *string) (*models.Profession, error)
|
||||
Qualifications(ctx context.Context, filter *models.QualificationFilter, limit *int, offset *int, sort []string) (*QualificationList, error)
|
||||
SimilarQualifications(ctx context.Context, qualificationID int, limit *int, offset *int, sort []string) (*QualificationList, error)
|
||||
Qualification(ctx context.Context, id *int, slug *string) (*models.Qualification, error)
|
||||
Questions(ctx context.Context, filter *models.QuestionFilter, limit *int, offset *int, sort []string) (*QuestionList, error)
|
||||
GenerateTest(ctx context.Context, qualificationIDs []int, limit *int) ([]*models.Question, error)
|
||||
|
@ -567,6 +569,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||
|
||||
return e.complexity.Query.Questions(childComplexity, args["filter"].(*models.QuestionFilter), args["limit"].(*int), args["offset"].(*int), args["sort"].([]string)), true
|
||||
|
||||
case "Query.similarQualifications":
|
||||
if e.complexity.Query.SimilarQualifications == nil {
|
||||
break
|
||||
}
|
||||
|
||||
args, err := ec.field_Query_similarQualifications_args(context.TODO(), rawArgs)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return e.complexity.Query.SimilarQualifications(childComplexity, args["qualificationID"].(int), args["limit"].(*int), args["offset"].(*int), args["sort"].([]string)), true
|
||||
|
||||
case "Query.user":
|
||||
if e.complexity.Query.User == nil {
|
||||
break
|
||||
|
@ -1004,6 +1018,12 @@ extend type Query {
|
|||
offset: Int
|
||||
sort: [String!]
|
||||
): QualificationList!
|
||||
similarQualifications(
|
||||
qualificationID: ID!
|
||||
limit: Int
|
||||
offset: Int
|
||||
sort: [String!]
|
||||
): QualificationList!
|
||||
qualification(id: Int, slug: String): Qualification
|
||||
}
|
||||
|
||||
|
@ -1745,6 +1765,48 @@ func (ec *executionContext) field_Query_questions_args(ctx context.Context, rawA
|
|||
return args, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_similarQualifications_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||
var err error
|
||||
args := map[string]interface{}{}
|
||||
var arg0 int
|
||||
if tmp, ok := rawArgs["qualificationID"]; ok {
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("qualificationID"))
|
||||
arg0, err = ec.unmarshalNID2int(ctx, tmp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
args["qualificationID"] = arg0
|
||||
var arg1 *int
|
||||
if tmp, ok := rawArgs["limit"]; ok {
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("limit"))
|
||||
arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
args["limit"] = arg1
|
||||
var arg2 *int
|
||||
if tmp, ok := rawArgs["offset"]; ok {
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("offset"))
|
||||
arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
args["offset"] = arg2
|
||||
var arg3 []string
|
||||
if tmp, ok := rawArgs["sort"]; ok {
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sort"))
|
||||
arg3, err = ec.unmarshalOString2ᚕstringᚄ(ctx, tmp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
args["sort"] = arg3
|
||||
return args, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) field_Query_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
|
||||
var err error
|
||||
args := map[string]interface{}{}
|
||||
|
@ -3555,6 +3617,48 @@ func (ec *executionContext) _Query_qualifications(ctx context.Context, field gra
|
|||
return ec.marshalNQualificationList2ᚖgithubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋgraphqlᚋgeneratedᚐQualificationList(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Query_similarQualifications(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
fc := &graphql.FieldContext{
|
||||
Object: "Query",
|
||||
Field: field,
|
||||
Args: nil,
|
||||
IsMethod: true,
|
||||
IsResolver: true,
|
||||
}
|
||||
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
rawArgs := field.ArgumentMap(ec.Variables)
|
||||
args, err := ec.field_Query_similarQualifications_args(ctx, rawArgs)
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
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.Query().SimilarQualifications(rctx, args["qualificationID"].(int), args["limit"].(*int), args["offset"].(*int), args["sort"].([]string))
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*QualificationList)
|
||||
fc.Result = res
|
||||
return ec.marshalNQualificationList2ᚖgithubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋgraphqlᚋgeneratedᚐQualificationList(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Query_qualification(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
|
@ -7340,6 +7444,20 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
|
|||
}
|
||||
return res
|
||||
})
|
||||
case "similarQualifications":
|
||||
field := field
|
||||
out.Concurrently(i, func() (res graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
}
|
||||
}()
|
||||
res = ec._Query_similarQualifications(ctx, field)
|
||||
if res == graphql.Null {
|
||||
atomic.AddUint32(&invalids, 1)
|
||||
}
|
||||
return res
|
||||
})
|
||||
case "qualification":
|
||||
field := field
|
||||
out.Concurrently(i, func() (res graphql.Marshaler) {
|
||||
|
|
|
@ -48,6 +48,28 @@ func (r *queryResolver) Qualifications(
|
|||
return list, err
|
||||
}
|
||||
|
||||
func (r *queryResolver) SimilarQualifications(
|
||||
ctx context.Context,
|
||||
qualificationID int,
|
||||
limit *int,
|
||||
offset *int,
|
||||
sort []string,
|
||||
) (*generated.QualificationList, error) {
|
||||
var err error
|
||||
list := &generated.QualificationList{}
|
||||
list.Items, list.Total, err = r.QualificationUsecase.GetSimilar(
|
||||
ctx,
|
||||
&qualification.GetSimilarConfig{
|
||||
Count: shouldCount(ctx),
|
||||
QualificationID: qualificationID,
|
||||
Limit: utils.SafeIntPointer(limit, qualification.FetchDefaultLimit),
|
||||
Offset: utils.SafeIntPointer(offset, 0),
|
||||
Sort: sort,
|
||||
},
|
||||
)
|
||||
return list, err
|
||||
}
|
||||
|
||||
func (r *queryResolver) Qualification(ctx context.Context, id *int, slug *string) (*models.Qualification, error) {
|
||||
if id != nil {
|
||||
return r.QualificationUsecase.GetByID(ctx, *id)
|
||||
|
|
|
@ -71,6 +71,12 @@ extend type Query {
|
|||
offset: Int
|
||||
sort: [String!]
|
||||
): QualificationList!
|
||||
similarQualifications(
|
||||
qualificationID: ID!
|
||||
limit: Int
|
||||
offset: Int
|
||||
sort: [String!]
|
||||
): QualificationList!
|
||||
qualification(id: Int, slug: String): Qualification
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue