Skip to content

Commit

Permalink
feat: support priority filter in resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Jan 24, 2023
1 parent e4ade97 commit 95fa077
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
11 changes: 10 additions & 1 deletion graphql/resolvers/Goal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ const connectionMap: Record<string, string> = {
false: 'disconnect',
};

const projectGoalsFilter = (data: { query: string; states: string[]; tags: string[]; owner: string[] }): any => {
const projectGoalsFilter = (data: {
query: string;
priority: string[];
states: string[];
tags: string[];
owner: string[];
}): any => {
const priorityFilter = data.priority.length ? { priority: { in: data.priority } } : {};

const statesFilter = data.states.length
? {
state: {
Expand Down Expand Up @@ -70,6 +78,7 @@ const projectGoalsFilter = (data: { query: string; states: string[]; tags: strin
},
},
],
...priorityFilter,
...statesFilter,
...tagsFilter,
...ownerFilter,
Expand Down
4 changes: 4 additions & 0 deletions graphql/resolvers/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ const connectionMap: Record<string, string> = {
const projectGoalsFilter = (data: {
key: string;
query: string;
priority: string[];
states: string[];
tags: string[];
owner: string[];
}): any => {
const priorityFilter = data.priority.length ? { priority: { in: data.priority } } : {};

const statesFilter = data.states.length
? {
state: {
Expand Down Expand Up @@ -77,6 +80,7 @@ const projectGoalsFilter = (data: {
project: {
key: data.key,
},
...priorityFilter,
...statesFilter,
...tagsFilter,
...ownerFilter,
Expand Down
5 changes: 4 additions & 1 deletion graphql/resolvers/Team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ const connectionMap: Record<string, string> = {
};

const projectGoalsFilter = (
data: { query: string; states: string[]; tags: string[]; owner: string[] },
data: { query: string; priority: string[]; states: string[]; tags: string[]; owner: string[] },
extra: any = {},
): any => {
const priorityFilter = data.priority.length ? { priority: { in: data.priority } } : {};

const statesFilter = data.states.length
? {
state: {
Expand Down Expand Up @@ -74,6 +76,7 @@ const projectGoalsFilter = (
},
},
],
...priorityFilter,
...statesFilter,
...tagsFilter,
...ownerFilter,
Expand Down
5 changes: 5 additions & 0 deletions graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ input ProjectDelete {
input ProjectGoalsCountInput {
key: String!
owner: [String!]!
priority: [String!]!
query: String!
states: [String!]!
tags: [String!]!
Expand All @@ -258,6 +259,7 @@ input ProjectGoalsInput {
offset: Int!
owner: [String!]!
pageSize: Int!
priority: [String!]!
query: String!
states: [String!]!
tags: [String!]!
Expand Down Expand Up @@ -406,6 +408,7 @@ input TeamDelete {

input TeamGoalsInput {
owner: [String!]!
priority: [String!]!
query: String!
slug: String!
states: [String!]!
Expand All @@ -414,6 +417,7 @@ input TeamGoalsInput {

input TeamProjectsInput {
owner: [String!]!
priority: [String!]!
query: String!
slug: String!
states: [String!]!
Expand Down Expand Up @@ -448,6 +452,7 @@ type User {

input UserGoalsInput {
owner: [String!]!
priority: [String!]!
query: String!
states: [String!]!
tags: [String!]!
Expand Down
5 changes: 5 additions & 0 deletions graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ export const ProjectGoalsInput = inputObjectType({
t.nonNull.string('key');
t.nonNull.int('pageSize');
t.nonNull.int('offset');
t.nonNull.list.nonNull.string('priority');
t.nonNull.list.nonNull.string('states');
t.nonNull.list.nonNull.string('tags');
t.nonNull.list.nonNull.string('owner');
Expand All @@ -470,6 +471,7 @@ export const ProjectGoalsInput = inputObjectType({
export const UserGoalsInput = inputObjectType({
name: 'UserGoalsInput',
definition(t) {
t.nonNull.list.nonNull.string('priority');
t.nonNull.list.nonNull.string('states');
t.nonNull.list.nonNull.string('tags');
t.nonNull.list.nonNull.string('owner');
Expand All @@ -481,6 +483,7 @@ export const ProjectGoalsCountInput = inputObjectType({
name: 'ProjectGoalsCountInput',
definition(t) {
t.nonNull.string('key');
t.nonNull.list.nonNull.string('priority');
t.nonNull.list.nonNull.string('states');
t.nonNull.list.nonNull.string('tags');
t.nonNull.list.nonNull.string('owner');
Expand Down Expand Up @@ -525,6 +528,7 @@ export const TeamProjectsInput = inputObjectType({
name: 'TeamProjectsInput',
definition(t) {
t.field(TeamModel.slug);
t.nonNull.list.nonNull.string('priority');
t.nonNull.list.nonNull.string('states');
t.nonNull.list.nonNull.string('tags');
t.nonNull.list.nonNull.string('owner');
Expand All @@ -536,6 +540,7 @@ export const TeamGoalsInput = inputObjectType({
name: 'TeamGoalsInput',
definition(t) {
t.field(TeamModel.slug);
t.nonNull.list.nonNull.string('priority');
t.nonNull.list.nonNull.string('states');
t.nonNull.list.nonNull.string('tags');
t.nonNull.list.nonNull.string('owner');
Expand Down

0 comments on commit 95fa077

Please sign in to comment.