Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds fact limit to to graphql #2868

Merged
merged 1 commit into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions services/api/src/resources/fact/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { logger } from '../../loggers/logger';

export const getFactsByEnvironmentId: ResolverFn = async (
{ id: environmentId, environmentAuthz },
{ keyFacts },
{ keyFacts, limit },
{ sqlClientPool, hasPermission }
) => {
const environment = await environmentHelpers(
Expand All @@ -25,7 +25,8 @@ export const getFactsByEnvironmentId: ResolverFn = async (
sqlClientPool,
Sql.selectFactsByEnvironmentId({
environmentId,
keyFacts
keyFacts,
limit
})
);

Expand Down
6 changes: 5 additions & 1 deletion services/api/src/resources/fact/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Sql = {
.where('f.id', fid)
.orderBy('f.id', 'asc')
.toString(),
selectFactsByEnvironmentId: ({ environmentId, keyFacts }) => {
selectFactsByEnvironmentId: ({ environmentId, keyFacts, limit }) => {
let q = knex('environment_fact as f')
.distinct(standardFactReturn)
.leftJoin('environment_fact_reference as r', 'r.fid', '=', 'f.id')
Expand All @@ -31,6 +31,10 @@ export const Sql = {
q.where('f.keyFact', keyFacts);
}

if (limit) {
q.limit(limit);
}

return q.orderBy('f.id', 'asc').toString()
},
insertFact: ({ environment, name, value, source, description, type, category, keyFact }) =>
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/typeDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ const typeDefs = gql`
advancedTasks: [AdvancedTaskDefinition]
services: [EnvironmentService]
problems(severity: [ProblemSeverityRating], source: [String]): [Problem]
facts(keyFacts: Boolean): [Fact]
facts(keyFacts: Boolean, limit: Int): [Fact]
openshift: Openshift
openshiftProjectPattern: String
kubernetes: Kubernetes
Expand Down