another part of bugfixes
This commit is contained in:
parent
a44afa628c
commit
82853734be
|
@ -907,13 +907,13 @@ extend type Query {
|
||||||
extend type Mutation {
|
extend type Mutation {
|
||||||
createProfession(input: ProfessionInput!): Profession
|
createProfession(input: ProfessionInput!): Profession
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
updateProfession(id: ID!, input: ProfessionInput!): Profession
|
updateProfession(id: ID!, input: ProfessionInput!): Profession
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
deleteProfessions(ids: [ID!]!): [Profession!]
|
deleteProfessions(ids: [ID!]!): [Profession!]
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
}
|
}
|
||||||
`, BuiltIn: false},
|
`, BuiltIn: false},
|
||||||
{Name: "schema/qualification.graphql", Input: `type Qualification {
|
{Name: "schema/qualification.graphql", Input: `type Qualification {
|
||||||
|
@ -995,13 +995,13 @@ extend type Query {
|
||||||
extend type Mutation {
|
extend type Mutation {
|
||||||
createQualification(input: QualificationInput!): Qualification
|
createQualification(input: QualificationInput!): Qualification
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
updateQualification(id: ID!, input: QualificationInput!): Qualification
|
updateQualification(id: ID!, input: QualificationInput!): Qualification
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
deleteQualifications(ids: [ID!]!): [Qualification!]
|
deleteQualifications(ids: [ID!]!): [Qualification!]
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
}
|
}
|
||||||
`, BuiltIn: false},
|
`, BuiltIn: false},
|
||||||
{Name: "schema/question.graphql", Input: `enum Answer {
|
{Name: "schema/question.graphql", Input: `enum Answer {
|
||||||
|
@ -1084,28 +1084,28 @@ extend type Query {
|
||||||
limit: Int
|
limit: Int
|
||||||
offset: Int
|
offset: Int
|
||||||
sort: [String!]
|
sort: [String!]
|
||||||
): QuestionList! @authenticated(yes: true) @hasRole(role: ADMIN)
|
): QuestionList! @authenticated(yes: true) @hasRole(role: Admin)
|
||||||
generateTest(qualificationIDs: [ID!]!, limit: Int): [Question!]
|
generateTest(qualificationIDs: [ID!]!, limit: Int): [Question!]
|
||||||
}
|
}
|
||||||
|
|
||||||
extend type Mutation {
|
extend type Mutation {
|
||||||
createQuestion(input: QuestionInput!): Question
|
createQuestion(input: QuestionInput!): Question
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
updateQuestion(id: ID!, input: QuestionInput!): Question
|
updateQuestion(id: ID!, input: QuestionInput!): Question
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
deleteQuestions(ids: [ID!]!): [Question!]
|
deleteQuestions(ids: [ID!]!): [Question!]
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
}
|
}
|
||||||
`, BuiltIn: false},
|
`, BuiltIn: false},
|
||||||
{Name: "schema/scalars.graphql", Input: `scalar Time
|
{Name: "schema/scalars.graphql", Input: `scalar Time
|
||||||
scalar Upload
|
scalar Upload
|
||||||
`, BuiltIn: false},
|
`, BuiltIn: false},
|
||||||
{Name: "schema/user.graphql", Input: `enum Role {
|
{Name: "schema/user.graphql", Input: `enum Role {
|
||||||
ADMIN
|
Admin
|
||||||
USER
|
User
|
||||||
}
|
}
|
||||||
|
|
||||||
type User {
|
type User {
|
||||||
|
@ -1172,24 +1172,24 @@ extend type Query {
|
||||||
limit: Int
|
limit: Int
|
||||||
offset: Int
|
offset: Int
|
||||||
sort: [String!]
|
sort: [String!]
|
||||||
): UserList! @authenticated(yes: true) @hasRole(role: ADMIN)
|
): UserList! @authenticated(yes: true) @hasRole(role: Admin)
|
||||||
user(id: Int!): User @authenticated(yes: true) @hasRole(role: ADMIN)
|
user(id: Int!): User @authenticated(yes: true) @hasRole(role: Admin)
|
||||||
me: User
|
me: User
|
||||||
}
|
}
|
||||||
|
|
||||||
extend type Mutation {
|
extend type Mutation {
|
||||||
createUser(input: UserInput!): User
|
createUser(input: UserInput!): User
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
updateUser(id: ID!, input: UserInput!): User
|
updateUser(id: ID!, input: UserInput!): User
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
updateManyUsers(ids: [ID!]!, input: UpdateManyUsersInput!): [User!]
|
updateManyUsers(ids: [ID!]!, input: UpdateManyUsersInput!): [User!]
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
deleteUsers(ids: [ID!]!): [User!]
|
deleteUsers(ids: [ID!]!): [User!]
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
signIn(
|
signIn(
|
||||||
email: String!
|
email: String!
|
||||||
password: String!
|
password: String!
|
||||||
|
@ -1854,7 +1854,7 @@ func (ec *executionContext) _Mutation_createProfession(ctx context.Context, fiel
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1927,7 +1927,7 @@ func (ec *executionContext) _Mutation_updateProfession(ctx context.Context, fiel
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2000,7 +2000,7 @@ func (ec *executionContext) _Mutation_deleteProfessions(ctx context.Context, fie
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2073,7 +2073,7 @@ func (ec *executionContext) _Mutation_createQualification(ctx context.Context, f
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2146,7 +2146,7 @@ func (ec *executionContext) _Mutation_updateQualification(ctx context.Context, f
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2219,7 +2219,7 @@ func (ec *executionContext) _Mutation_deleteQualifications(ctx context.Context,
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2292,7 +2292,7 @@ func (ec *executionContext) _Mutation_createQuestion(ctx context.Context, field
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2365,7 +2365,7 @@ func (ec *executionContext) _Mutation_updateQuestion(ctx context.Context, field
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2438,7 +2438,7 @@ func (ec *executionContext) _Mutation_deleteQuestions(ctx context.Context, field
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2511,7 +2511,7 @@ func (ec *executionContext) _Mutation_createUser(ctx context.Context, field grap
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2584,7 +2584,7 @@ func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field grap
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2657,7 +2657,7 @@ func (ec *executionContext) _Mutation_updateManyUsers(ctx context.Context, field
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2730,7 +2730,7 @@ func (ec *executionContext) _Mutation_deleteUsers(ctx context.Context, field gra
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -3573,7 +3573,7 @@ func (ec *executionContext) _Query_questions(ctx context.Context, field graphql.
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -3688,7 +3688,7 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -3764,7 +3764,7 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle
|
||||||
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
return ec.directives.Authenticated(ctx, nil, directive0, yes)
|
||||||
}
|
}
|
||||||
directive2 := func(ctx context.Context) (interface{}, error) {
|
directive2 := func(ctx context.Context) (interface{}, error) {
|
||||||
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "ADMIN")
|
role, err := ec.unmarshalNRole2githubᚗcomᚋzdamᚑegzaminᚑzawodowyᚋbackendᚋinternalᚋmodelsᚐRole(ctx, "Admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,11 +51,11 @@ extend type Query {
|
||||||
extend type Mutation {
|
extend type Mutation {
|
||||||
createProfession(input: ProfessionInput!): Profession
|
createProfession(input: ProfessionInput!): Profession
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
updateProfession(id: ID!, input: ProfessionInput!): Profession
|
updateProfession(id: ID!, input: ProfessionInput!): Profession
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
deleteProfessions(ids: [ID!]!): [Profession!]
|
deleteProfessions(ids: [ID!]!): [Profession!]
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,11 +77,11 @@ extend type Query {
|
||||||
extend type Mutation {
|
extend type Mutation {
|
||||||
createQualification(input: QualificationInput!): Qualification
|
createQualification(input: QualificationInput!): Qualification
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
updateQualification(id: ID!, input: QualificationInput!): Qualification
|
updateQualification(id: ID!, input: QualificationInput!): Qualification
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
deleteQualifications(ids: [ID!]!): [Qualification!]
|
deleteQualifications(ids: [ID!]!): [Qualification!]
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,18 +78,18 @@ extend type Query {
|
||||||
limit: Int
|
limit: Int
|
||||||
offset: Int
|
offset: Int
|
||||||
sort: [String!]
|
sort: [String!]
|
||||||
): QuestionList! @authenticated(yes: true) @hasRole(role: ADMIN)
|
): QuestionList! @authenticated(yes: true) @hasRole(role: Admin)
|
||||||
generateTest(qualificationIDs: [ID!]!, limit: Int): [Question!]
|
generateTest(qualificationIDs: [ID!]!, limit: Int): [Question!]
|
||||||
}
|
}
|
||||||
|
|
||||||
extend type Mutation {
|
extend type Mutation {
|
||||||
createQuestion(input: QuestionInput!): Question
|
createQuestion(input: QuestionInput!): Question
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
updateQuestion(id: ID!, input: QuestionInput!): Question
|
updateQuestion(id: ID!, input: QuestionInput!): Question
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
deleteQuestions(ids: [ID!]!): [Question!]
|
deleteQuestions(ids: [ID!]!): [Question!]
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
enum Role {
|
enum Role {
|
||||||
ADMIN
|
Admin
|
||||||
USER
|
User
|
||||||
}
|
}
|
||||||
|
|
||||||
type User {
|
type User {
|
||||||
|
@ -67,24 +67,24 @@ extend type Query {
|
||||||
limit: Int
|
limit: Int
|
||||||
offset: Int
|
offset: Int
|
||||||
sort: [String!]
|
sort: [String!]
|
||||||
): UserList! @authenticated(yes: true) @hasRole(role: ADMIN)
|
): UserList! @authenticated(yes: true) @hasRole(role: Admin)
|
||||||
user(id: Int!): User @authenticated(yes: true) @hasRole(role: ADMIN)
|
user(id: Int!): User @authenticated(yes: true) @hasRole(role: Admin)
|
||||||
me: User
|
me: User
|
||||||
}
|
}
|
||||||
|
|
||||||
extend type Mutation {
|
extend type Mutation {
|
||||||
createUser(input: UserInput!): User
|
createUser(input: UserInput!): User
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
updateUser(id: ID!, input: UserInput!): User
|
updateUser(id: ID!, input: UserInput!): User
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
updateManyUsers(ids: [ID!]!, input: UpdateManyUsersInput!): [User!]
|
updateManyUsers(ids: [ID!]!, input: UpdateManyUsersInput!): [User!]
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
deleteUsers(ids: [ID!]!): [User!]
|
deleteUsers(ids: [ID!]!): [User!]
|
||||||
@authenticated(yes: true)
|
@authenticated(yes: true)
|
||||||
@hasRole(role: ADMIN)
|
@hasRole(role: Admin)
|
||||||
signIn(
|
signIn(
|
||||||
email: String!
|
email: String!
|
||||||
password: String!
|
password: String!
|
||||||
|
|
|
@ -70,10 +70,10 @@ func (input *ProfessionInput) ToProfession() *Profession {
|
||||||
func (input *ProfessionInput) ApplyUpdate(q *orm.Query) (*orm.Query, error) {
|
func (input *ProfessionInput) ApplyUpdate(q *orm.Query) (*orm.Query, error) {
|
||||||
if !input.IsEmpty() {
|
if !input.IsEmpty() {
|
||||||
if input.Name != nil {
|
if input.Name != nil {
|
||||||
q.Set("name = ?", *input.Name)
|
q = q.Set("name = ?", *input.Name)
|
||||||
}
|
}
|
||||||
if input.Description != nil {
|
if input.Description != nil {
|
||||||
q.Set("description = ?", *input.Description)
|
q = q.Set("description = ?", *input.Description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ type QualificationToProfession struct {
|
||||||
QualificationID int `pg:"on_delete:CASCADE,unique:group_1" json:"qualificationID" xml:"qualificationID" gqlgen:"qualificationID"`
|
QualificationID int `pg:"on_delete:CASCADE,unique:group_1" json:"qualificationID" xml:"qualificationID" gqlgen:"qualificationID"`
|
||||||
Qualification *Qualification `pg:"rel:has-one" json:"qualification" xml:"qualification" gqlgen:"qualification"`
|
Qualification *Qualification `pg:"rel:has-one" json:"qualification" xml:"qualification" gqlgen:"qualification"`
|
||||||
ProfessionID int `pg:"on_delete:CASCADE,unique:group_1" json:"professionID" xml:"professionID" gqlgen:"professionID"`
|
ProfessionID int `pg:"on_delete:CASCADE,unique:group_1" json:"professionID" xml:"professionID" gqlgen:"professionID"`
|
||||||
Profession *Qualification `pg:"rel:has-one" json:"profession" xml:"profession" gqlgen:"profession"`
|
Profession *Profession `pg:"rel:has-one" json:"profession" xml:"profession" gqlgen:"profession"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type QualificationInput struct {
|
type QualificationInput struct {
|
||||||
|
@ -101,10 +101,16 @@ func (input *QualificationInput) ToQualification() *Qualification {
|
||||||
func (input *QualificationInput) ApplyUpdate(q *orm.Query) (*orm.Query, error) {
|
func (input *QualificationInput) ApplyUpdate(q *orm.Query) (*orm.Query, error) {
|
||||||
if !input.IsEmpty() {
|
if !input.IsEmpty() {
|
||||||
if input.Name != nil {
|
if input.Name != nil {
|
||||||
q.Set("name = ?", *input.Name)
|
q = q.Set("name = ?", *input.Name)
|
||||||
|
}
|
||||||
|
if input.Code != nil {
|
||||||
|
q = q.Set("code = ?", *input.Code)
|
||||||
|
}
|
||||||
|
if input.Formula != nil {
|
||||||
|
q = q.Set("formula = ?", *input.Formula)
|
||||||
}
|
}
|
||||||
if input.Description != nil {
|
if input.Description != nil {
|
||||||
q.Set("description = ?", *input.Description)
|
q = q.Set("description = ?", *input.Description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,31 +130,31 @@ func (input *QuestionInput) ToQuestion() *Question {
|
||||||
func (input *QuestionInput) ApplyUpdate(q *orm.Query) (*orm.Query, error) {
|
func (input *QuestionInput) ApplyUpdate(q *orm.Query) (*orm.Query, error) {
|
||||||
if !input.IsEmpty() {
|
if !input.IsEmpty() {
|
||||||
if input.Content != nil {
|
if input.Content != nil {
|
||||||
q.Set("content = ?", *input.Content)
|
q = q.Set("content = ?", *input.Content)
|
||||||
}
|
}
|
||||||
if input.From != nil {
|
if input.From != nil {
|
||||||
q.Set("from = ?", *input.From)
|
q = q.Set("from = ?", *input.From)
|
||||||
}
|
}
|
||||||
if input.Explanation != nil {
|
if input.Explanation != nil {
|
||||||
q.Set("explanation = ?", *input.Explanation)
|
q = q.Set("explanation = ?", *input.Explanation)
|
||||||
}
|
}
|
||||||
if input.CorrectAnswer != nil {
|
if input.CorrectAnswer != nil {
|
||||||
q.Set("correct_answer = ?", *input.CorrectAnswer)
|
q = q.Set("correct_answer = ?", *input.CorrectAnswer)
|
||||||
}
|
}
|
||||||
if input.AnswerA != nil {
|
if input.AnswerA != nil {
|
||||||
q.Set("answer_a = ?", *input.AnswerA)
|
q = q.Set("answer_a = ?", *input.AnswerA)
|
||||||
}
|
}
|
||||||
if input.AnswerB != nil {
|
if input.AnswerB != nil {
|
||||||
q.Set("answer_b = ?", *input.AnswerB)
|
q = q.Set("answer_b = ?", *input.AnswerB)
|
||||||
}
|
}
|
||||||
if input.AnswerC != nil {
|
if input.AnswerC != nil {
|
||||||
q.Set("answer_c = ?", *input.AnswerC)
|
q = q.Set("answer_c = ?", *input.AnswerC)
|
||||||
}
|
}
|
||||||
if input.AnswerD != nil {
|
if input.AnswerD != nil {
|
||||||
q.Set("answer_d = ?", *input.AnswerD)
|
q = q.Set("answer_d = ?", *input.AnswerD)
|
||||||
}
|
}
|
||||||
if input.QualificationID != nil {
|
if input.QualificationID != nil {
|
||||||
q.Set("qualification_id = ?", *input.QualificationID)
|
q = q.Set("qualification_id = ?", *input.QualificationID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ func (input *UserInput) ToUser() *User {
|
||||||
func (input *UserInput) ApplyUpdate(q *orm.Query) (*orm.Query, error) {
|
func (input *UserInput) ApplyUpdate(q *orm.Query) (*orm.Query, error) {
|
||||||
if !input.IsEmpty() {
|
if !input.IsEmpty() {
|
||||||
if input.DisplayName != nil {
|
if input.DisplayName != nil {
|
||||||
q.Set("display_name = ?", *input.DisplayName)
|
q = q.Set("display_name = ?", *input.DisplayName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if input.Password != nil {
|
if input.Password != nil {
|
||||||
|
@ -112,19 +112,19 @@ func (input *UserInput) ApplyUpdate(q *orm.Query) (*orm.Query, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return q, err
|
return q, err
|
||||||
}
|
}
|
||||||
q.Set("password = ?", string(hashedPassword))
|
q = q.Set("password = ?", string(hashedPassword))
|
||||||
}
|
}
|
||||||
|
|
||||||
if input.Email != nil {
|
if input.Email != nil {
|
||||||
q.Set("name = ?", *input.Email)
|
q = q.Set("name = ?", *input.Email)
|
||||||
}
|
}
|
||||||
|
|
||||||
if input.Role != nil {
|
if input.Role != nil {
|
||||||
q.Set("role = ?", *input.Role)
|
q = q.Set("role = ?", *input.Role)
|
||||||
}
|
}
|
||||||
|
|
||||||
if input.Activated != nil {
|
if input.Activated != nil {
|
||||||
q.Set("activated = ?", *input.Activated)
|
q = q.Set("activated = ?", *input.Activated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,9 @@ func (repo *pgRepository) Store(ctx context.Context, input *models.ProfessionInp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *pgRepository) UpdateMany(ctx context.Context, f *models.ProfessionFilter, input *models.ProfessionInput) ([]*models.Profession, error) {
|
func (repo *pgRepository) UpdateMany(ctx context.Context, f *models.ProfessionFilter, input *models.ProfessionInput) ([]*models.Profession, error) {
|
||||||
items := []*models.Profession{}
|
|
||||||
if _, err := repo.
|
if _, err := repo.
|
||||||
Model(&items).
|
Model(&models.Profession{}).
|
||||||
Context(ctx).
|
Context(ctx).
|
||||||
Returning("*").
|
|
||||||
Apply(input.ApplyUpdate).
|
Apply(input.ApplyUpdate).
|
||||||
Apply(f.Where).
|
Apply(f.Where).
|
||||||
Update(); err != nil && err != pg.ErrNoRows {
|
Update(); err != nil && err != pg.ErrNoRows {
|
||||||
|
@ -58,6 +56,13 @@ func (repo *pgRepository) UpdateMany(ctx context.Context, f *models.ProfessionFi
|
||||||
}
|
}
|
||||||
return nil, errorutils.Wrap(err, messageFailedToSaveModel)
|
return nil, errorutils.Wrap(err, messageFailedToSaveModel)
|
||||||
}
|
}
|
||||||
|
items, _, err := repo.Fetch(ctx, &profession.FetchConfig{
|
||||||
|
Count: false,
|
||||||
|
Filter: f,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
sqlutils "github.com/zdam-egzamin-zawodowy/backend/pkg/utils/sql"
|
sqlutils "github.com/zdam-egzamin-zawodowy/backend/pkg/utils/sql"
|
||||||
|
|
||||||
errorutils "github.com/zdam-egzamin-zawodowy/backend/pkg/utils/error"
|
errorutils "github.com/zdam-egzamin-zawodowy/backend/pkg/utils/error"
|
||||||
|
@ -68,19 +70,28 @@ func (repo *pgRepository) UpdateMany(
|
||||||
) ([]*models.Qualification, error) {
|
) ([]*models.Qualification, error) {
|
||||||
items := []*models.Qualification{}
|
items := []*models.Qualification{}
|
||||||
err := repo.RunInTransaction(ctx, func(tx *pg.Tx) error {
|
err := repo.RunInTransaction(ctx, func(tx *pg.Tx) error {
|
||||||
if _, err := tx.
|
if input.Name != nil || input.Code != nil || input.Description != nil || input.Formula != nil {
|
||||||
|
if _, err := tx.
|
||||||
|
Model(&models.Qualification{}).
|
||||||
|
Context(ctx).
|
||||||
|
Apply(input.ApplyUpdate).
|
||||||
|
Apply(f.Where).
|
||||||
|
Update(); err != nil && err != pg.ErrNoRows {
|
||||||
|
if strings.Contains(err.Error(), "name") {
|
||||||
|
return errorutils.Wrap(err, messageNameIsAlreadyTaken)
|
||||||
|
} else if strings.Contains(err.Error(), "code") {
|
||||||
|
return errorutils.Wrap(err, messageCodeIsAlreadyTaken)
|
||||||
|
}
|
||||||
|
return errorutils.Wrap(err, messageFailedToSaveModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := tx.
|
||||||
Model(&items).
|
Model(&items).
|
||||||
Context(ctx).
|
Context(ctx).
|
||||||
Returning("*").
|
|
||||||
Apply(input.ApplyUpdate).
|
|
||||||
Apply(f.Where).
|
Apply(f.Where).
|
||||||
Update(); err != nil && err != pg.ErrNoRows {
|
Select(); err != nil && err != pg.ErrNoRows {
|
||||||
if strings.Contains(err.Error(), "name") {
|
return errorutils.Wrap(err, messageFailedToFetchModel)
|
||||||
return errorutils.Wrap(err, messageNameIsAlreadyTaken)
|
|
||||||
} else if strings.Contains(err.Error(), "code") {
|
|
||||||
return errorutils.Wrap(err, messageCodeIsAlreadyTaken)
|
|
||||||
}
|
|
||||||
return errorutils.Wrap(err, messageFailedToSaveModel)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qualificationIDs := make([]int, len(items))
|
qualificationIDs := make([]int, len(items))
|
||||||
|
@ -107,7 +118,10 @@ func (repo *pgRepository) UpdateMany(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tx.Model(&toInsert).Insert()
|
_, err := tx.Model(&toInsert).Insert()
|
||||||
|
if err != nil {
|
||||||
|
logrus.Debug(errors.Wrap(err, "Couldn't insert []*models.QualificationToProfession{}"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@ package usecase
|
||||||
|
|
||||||
const (
|
const (
|
||||||
messageInvalidID = "Niepoprawne ID."
|
messageInvalidID = "Niepoprawne ID."
|
||||||
messageItemNotFound = "Nie znaleziono zawodu."
|
messageItemNotFound = "Nie znaleziono kwalifikacji."
|
||||||
messageEmptyPayload = "Nie wprowadzono jakichkolwiek danych."
|
messageEmptyPayload = "Nie wprowadzono jakichkolwiek danych."
|
||||||
messageNameIsRequired = "Nazwa zawodu jest wymagana."
|
messageNameIsRequired = "Nazwa kwalifikacji jest wymagana."
|
||||||
messageCodeIsRequired = "Oznaczenie kwalifikacji jest wymagane."
|
messageCodeIsRequired = "Oznaczenie kwalifikacji jest wymagane."
|
||||||
messageNameIsTooLong = "Nazwa zawodu może się składać z maksymalnie %d znaków."
|
messageNameIsTooLong = "Nazwa kwalifikacji może się składać z maksymalnie %d znaków."
|
||||||
)
|
)
|
||||||
|
|
|
@ -45,11 +45,9 @@ func (repo *pgRepository) Store(ctx context.Context, input *models.UserInput) (*
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *pgRepository) UpdateMany(ctx context.Context, f *models.UserFilter, input *models.UserInput) ([]*models.User, error) {
|
func (repo *pgRepository) UpdateMany(ctx context.Context, f *models.UserFilter, input *models.UserInput) ([]*models.User, error) {
|
||||||
items := []*models.User{}
|
|
||||||
if _, err := repo.
|
if _, err := repo.
|
||||||
Model(&items).
|
Model(&models.User{}).
|
||||||
Context(ctx).
|
Context(ctx).
|
||||||
Returning("*").
|
|
||||||
Apply(input.ApplyUpdate).
|
Apply(input.ApplyUpdate).
|
||||||
Apply(f.Where).
|
Apply(f.Where).
|
||||||
Update(); err != nil && err != pg.ErrNoRows {
|
Update(); err != nil && err != pg.ErrNoRows {
|
||||||
|
@ -58,6 +56,13 @@ func (repo *pgRepository) UpdateMany(ctx context.Context, f *models.UserFilter,
|
||||||
}
|
}
|
||||||
return nil, errorutils.Wrap(err, messageFailedToSaveModel)
|
return nil, errorutils.Wrap(err, messageFailedToSaveModel)
|
||||||
}
|
}
|
||||||
|
items, _, err := repo.Fetch(ctx, &user.FetchConfig{
|
||||||
|
Count: false,
|
||||||
|
Filter: f,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ func (ucase *usecase) validateInput(input *models.UserInput, opts validateOption
|
||||||
return fmt.Errorf(messageInvalidRole)
|
return fmt.Errorf(messageInvalidRole)
|
||||||
}
|
}
|
||||||
} else if !opts.acceptNilValues {
|
} else if !opts.acceptNilValues {
|
||||||
return fmt.Errorf(messagePasswordIsRequired)
|
return fmt.Errorf(messageInvalidRole)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Reference in New Issue