Skip to content
Permalink
Browse files

Merge pull request #1109 from amazeeio/issue_1038

Add `order` field to `allProjects` and `allEnvironments` GraphQL API endpoints
  • Loading branch information...
Schnitzel committed Jun 1, 2019
2 parents 28788b6 + f510284 commit 2a4b2c722c0161e49dccf4417418de1bf36df157
@@ -658,8 +658,11 @@ const getAllEnvironments = async (
'deleted = "0000-00-00 00:00:00"',
]);

const prep = prepare(sqlClient, `SELECT * FROM environment ${where}`);
const order = args.order ? ` ORDER BY ${R.toLower(args.order)} ASC` : ''

const prep = prepare(sqlClient, `SELECT * FROM environment ${where}${order}`);
const rows = await query(sqlClient, prep(args));

return rows;
};

@@ -46,7 +46,9 @@ const getAllProjects = async (
),
]);

const prep = prepare(sqlClient, `SELECT * FROM project ${where}`);
const order = args.order ? ` ORDER BY ${R.toLower(args.order)} ASC` : ''

const prep = prepare(sqlClient, `SELECT * FROM project ${where}${order}`);
const rows = await query(sqlClient, prep(args));

return rows;
@@ -66,6 +66,16 @@ const typeDefs = gql`
FAILED
}
enum EnvOrderType {
NAME
UPDATED
}
enum ProjectOrderType {
NAME
CREATED
}
type File {
id: Int
filename: String
@@ -472,7 +482,7 @@ const typeDefs = gql`
"""
Returns all Project Objects matching given filters (all if no filter defined)
"""
allProjects(createdAfter: String, gitUrl: String): [Project]
allProjects(createdAfter: String, gitUrl: String, order: ProjectOrderType): [Project]
"""
Returns all Customer Objects matching given filter (all if no filter defined)
"""
@@ -484,7 +494,7 @@ const typeDefs = gql`
"""
Returns all Environments matching given filter (all if no filter defined)
"""
allEnvironments(createdAfter: String, type: EnvType): [Environment]
allEnvironments(createdAfter: String, type: EnvType, order: EnvOrderType): [Environment]
}
# Must provide id OR name

0 comments on commit 2a4b2c7

Please sign in to comment.
You can’t perform that action at this time.