Skip to content
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
2 changes: 2 additions & 0 deletions components/ui/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
"@graphql-codegen/schema-ast": "^1.18.1",
"@graphql-codegen/typescript": "1.21.0",
"@graphql-codegen/typescript-resolvers": "1.18.2",
"@graphql-tools/mock": "^9.0.25",
"@graphql-tools/schema": "^10.0.25",
"@types/lodash": "^4.14.191",
"@types/uuid": "^8.3.0",
"@types/webpack-env": "^1.16.0",
Expand Down
14 changes: 8 additions & 6 deletions components/ui/graphql/src/data/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { KeyValueCache } from '@apollo/utils.keyvaluecache';
import { sortBy } from 'lodash';

import { environment } from '../environment';
import { CreateJobParams, Job, JobDetailParams, JobDetails, JobFilters, JobMessage } from '../generated/typings';
import { CreateJobParams, Job, JobDetails, JobFilters, JobMessage } from '../generated/typings';
import { VolumesAPI } from './volumes';

export class JobsAPI extends RESTDataSource {
Expand All @@ -26,8 +26,9 @@ export class JobsAPI extends RESTDataSource {
}

// QUERIES //
async getJobs(filters: JobFilters[] | undefined | null): Promise<Job[]> {
const jobsres = await this.get(`${this.baseURL!}jobs/`) || [];
async getJobs(filters: JobFilters[] | undefined | null, top = 10): Promise<Job[]> {
const jobsres = await this.get(`${this.baseURL!}jobs?top=${top}`) || [];

let jobs: Job[] = jobsres.map((r: any) => this.jobReducer(r));

if (filters) {
Expand All @@ -38,13 +39,14 @@ export class JobsAPI extends RESTDataSource {
return jobs;
}

async getJobDetails(jobDetailParams: JobDetailParams): Promise<JobDetails> {
const sanitizedURI = jobDetailParams.resultsFolderURI.replace('/home/idies/workspace/', '');
async getJobDetails(jobId: string): Promise<JobDetails> {
const job = await this.get(`${this.baseURL!}jobs/${jobId}`);
const sanitizedURI = job.resultsFolderURI.replace('/home/idies/workspace/', '');
const jobJsontree = await this.volumesAPI.getFilesByVolume(sanitizedURI) || {};
const readMeFile = await this.get(`${this.filesURL}file/${sanitizedURI}/README.md`) || {};

return {
id: jobDetailParams.jobID,
job: this.jobReducer(job),
summary: readMeFile || 'No summary available',
files: jobJsontree.root.files || []
};
Expand Down
11 changes: 3 additions & 8 deletions components/ui/graphql/src/generated/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,9 @@ type Job {
username: String
}

input JobDetailParams {
jobID: ID!
resultsFolderURI: String!
}

type JobDetails {
files: [File!]!
id: ID!
job: Job!
summary: String!
}

Expand Down Expand Up @@ -223,8 +218,8 @@ type Query {
getDatasets(volumeType: VolumeType!): [Dataset!]!
getDomainByID(id: ID!): Domain
getDomains: [Domain!]!
getJobDetails(jobDetailParams: JobDetailParams!): JobDetails!
getJobs(filters: [JobFilters!]): [Job!]!
getJobDetails(jobId: ID!): JobDetails!
getJobs(filters: [JobFilters!], top: Int): [Job!]!
getJsonTree(volumeName: String!): JSONTree!
getUser: User!
getVolumes: FileService
Expand Down
16 changes: 5 additions & 11 deletions components/ui/graphql/src/generated/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,10 @@ export type Job = {
username?: Maybe<Scalars['String']>;
};

export type JobDetailParams = {
jobID: Scalars['ID'];
resultsFolderURI: Scalars['String'];
};

export type JobDetails = {
__typename?: 'JobDetails';
files: Array<File>;
id: Scalars['ID'];
job: Job;
summary: Scalars['String'];
};

Expand Down Expand Up @@ -310,12 +305,13 @@ export type QueryGetDomainByIdArgs = {


export type QueryGetJobDetailsArgs = {
jobDetailParams: JobDetailParams;
jobId: Scalars['ID'];
};


export type QueryGetJobsArgs = {
filters?: InputMaybe<Array<JobFilters>>;
top?: InputMaybe<Scalars['Int']>;
};


Expand Down Expand Up @@ -483,7 +479,6 @@ export type ResolversTypes = {
JSONObject: ResolverTypeWrapper<Scalars['JSONObject']>;
JSONTree: ResolverTypeWrapper<JsonTree>;
Job: ResolverTypeWrapper<Job>;
JobDetailParams: JobDetailParams;
JobDetails: ResolverTypeWrapper<JobDetails>;
JobFilters: JobFilters;
JobMessage: ResolverTypeWrapper<JobMessage>;
Expand Down Expand Up @@ -527,7 +522,6 @@ export type ResolversParentTypes = {
JSONObject: Scalars['JSONObject'];
JSONTree: JsonTree;
Job: Job;
JobDetailParams: JobDetailParams;
JobDetails: JobDetails;
JobFilters: JobFilters;
JobMessage: JobMessage;
Expand Down Expand Up @@ -697,7 +691,7 @@ export type JobResolvers<ContextType = Context, ParentType extends ResolversPare

export type JobDetailsResolvers<ContextType = Context, ParentType extends ResolversParentTypes['JobDetails'] = ResolversParentTypes['JobDetails']> = {
files?: Resolver<Array<ResolversTypes['File']>, ParentType, ContextType>;
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
job?: Resolver<ResolversTypes['Job'], ParentType, ContextType>;
summary?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
Expand Down Expand Up @@ -732,7 +726,7 @@ export type QueryResolvers<ContextType = Context, ParentType extends ResolversPa
getDatasets?: Resolver<Array<ResolversTypes['Dataset']>, ParentType, ContextType, RequireFields<QueryGetDatasetsArgs, 'volumeType'>>;
getDomainByID?: Resolver<Maybe<ResolversTypes['Domain']>, ParentType, ContextType, RequireFields<QueryGetDomainByIdArgs, 'id'>>;
getDomains?: Resolver<Array<ResolversTypes['Domain']>, ParentType, ContextType>;
getJobDetails?: Resolver<ResolversTypes['JobDetails'], ParentType, ContextType, RequireFields<QueryGetJobDetailsArgs, 'jobDetailParams'>>;
getJobDetails?: Resolver<ResolversTypes['JobDetails'], ParentType, ContextType, RequireFields<QueryGetJobDetailsArgs, 'jobId'>>;
getJobs?: Resolver<Array<ResolversTypes['Job']>, ParentType, ContextType, Partial<QueryGetJobsArgs>>;
getJsonTree?: Resolver<ResolversTypes['JSONTree'], ParentType, ContextType, RequireFields<QueryGetJsonTreeArgs, 'volumeName'>>;
getUser?: Resolver<ResolversTypes['User'], ParentType, ContextType>;
Expand Down
13 changes: 10 additions & 3 deletions components/ui/graphql/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import { ApolloServer } from '@apollo/server';
import { expressMiddleware } from '@apollo/server/express4';
import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default';
import { addMocksToSchema } from '@graphql-tools/mock';
import { makeExecutableSchema } from '@graphql-tools/schema';
import express from 'express';
import http from 'http';
import cors from 'cors';
Expand Down Expand Up @@ -38,10 +40,15 @@ export type Context = {
const app = express();
const httpServer = http.createServer(app);

const schema = makeExecutableSchema({ typeDefs, resolvers });
const server = new ApolloServer<Context>({
typeDefs,
resolvers,
plugins: process.env.NODE_ENV !== 'production' ?
schema: process.env.IDIES_ENV === 'test' ? addMocksToSchema(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this is better called SCISERVER_ENV

{
schema,
mocks: { DateTime: () => new Date() }
}
) : schema,
plugins: process.env.IDIES_ENV !== 'production' ?
[
// eslint-disable-next-line new-cap
ApolloServerPluginLandingPageLocalDefault({ footer: false })
Expand Down
8 changes: 4 additions & 4 deletions components/ui/graphql/src/resolvers/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { MutationResolvers, QueryResolvers } from '../generated/typings';

export const queryResolvers: QueryResolvers = {
// eslint-disable-next-line no-empty-pattern
getJobs: async (_, { filters }, { dataSources }) => {
return dataSources.jobsAPI.getJobs(filters);
getJobs: async (_, { filters, top }, { dataSources }) => {
return dataSources.jobsAPI.getJobs(filters, top || undefined);
},
getJobDetails: async (_, { jobDetailParams }, { dataSources }) => {
return dataSources.jobsAPI.getJobDetails(jobDetailParams);
getJobDetails: async (_, { jobId }, { dataSources }) => {
return dataSources.jobsAPI.getJobDetails(jobId);
}
};

Expand Down
11 changes: 3 additions & 8 deletions components/ui/graphql/src/types/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const typeDefs = gql`
}

type JobDetails {
id: ID!
job: Job!
summary: String!
files: [File!]!
}
Expand All @@ -65,15 +65,10 @@ export const typeDefs = gql`
submitterDID: String!
scriptURI: String!
}

input JobDetailParams {
jobID: ID!
resultsFolderURI: String!
}

type Query {
getJobs(filters: [JobFilters!]): [Job!]!
getJobDetails(jobDetailParams: JobDetailParams!): JobDetails!
getJobs(filters: [JobFilters!], top: Int): [Job!]!
getJobDetails(jobId: ID!): JobDetails!
}

type Mutation {
Expand Down
64 changes: 63 additions & 1 deletion components/ui/graphql/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,24 @@
"@graphql-tools/utils" "^9.2.1"
tslib "^2.4.0"

"@graphql-tools/merge@^9.1.1":
version "9.1.1"
resolved "https://registry.yarnpkg.com/@graphql-tools/merge/-/merge-9.1.1.tgz#6a51775f5ba6bdef213def1fd277536f9468b44c"
integrity sha512-BJ5/7Y7GOhTuvzzO5tSBFL4NGr7PVqTJY3KeIDlVTT8YLcTXtBR+hlrC3uyEym7Ragn+zyWdHeJ9ev+nRX1X2w==
dependencies:
"@graphql-tools/utils" "^10.9.1"
tslib "^2.4.0"

"@graphql-tools/mock@^9.0.25":
version "9.0.25"
resolved "https://registry.yarnpkg.com/@graphql-tools/mock/-/mock-9.0.25.tgz#46a34599dcd8ce770371a48f082601441e8c2a8f"
integrity sha512-rarXnRw8oDraR8kR8GekwmOO5tbOlJcoe9CFGgCjRehfDxA3qxnTpJTtS5pwhBNvRdrEQXKtt6UGevbMRB0XSw==
dependencies:
"@graphql-tools/schema" "^10.0.25"
"@graphql-tools/utils" "^10.9.1"
fast-json-stable-stringify "^2.1.0"
tslib "^2.4.0"

"@graphql-tools/optimize@^1.3.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@graphql-tools/optimize/-/optimize-1.4.0.tgz#20d6a9efa185ef8fc4af4fd409963e0907c6e112"
Expand Down Expand Up @@ -1084,6 +1102,15 @@
"@graphql-tools/utils" "^9.2.1"
tslib "^2.4.0"

"@graphql-tools/schema@^10.0.25":
version "10.0.25"
resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-10.0.25.tgz#73de08bc765f482cde334562a1bebe95a2e5a3c4"
integrity sha512-/PqE8US8kdQ7lB9M5+jlW8AyVjRGCKU7TSktuW3WNKSKmDO0MK1wakvb5gGdyT49MjAIb4a3LWxIpwo5VygZuw==
dependencies:
"@graphql-tools/merge" "^9.1.1"
"@graphql-tools/utils" "^10.9.1"
tslib "^2.4.0"

"@graphql-tools/schema@^9.0.0", "@graphql-tools/schema@^9.0.18", "@graphql-tools/schema@^9.0.19":
version "9.0.19"
resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-9.0.19.tgz#c4ad373b5e1b8a0cf365163435b7d236ebdd06e7"
Expand Down Expand Up @@ -1113,6 +1140,17 @@
value-or-promise "^1.0.11"
ws "^8.12.0"

"@graphql-tools/utils@^10.9.1":
version "10.9.1"
resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-10.9.1.tgz#ff4067256f2080db0c66f4475858f29a8da65ecf"
integrity sha512-B1wwkXk9UvU7LCBkPs8513WxOQ2H8Fo5p8HR1+Id9WmYE5+bd51vqN+MbrqvWczHCH2gwkREgHJN88tE0n1FCw==
dependencies:
"@graphql-typed-document-node/core" "^3.1.1"
"@whatwg-node/promise-helpers" "^1.0.0"
cross-inspect "1.0.1"
dset "^3.1.4"
tslib "^2.4.0"

"@graphql-tools/utils@^9.0.0", "@graphql-tools/utils@^9.1.1", "@graphql-tools/utils@^9.2.1":
version "9.2.1"
resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-9.2.1.tgz#1b3df0ef166cfa3eae706e3518b17d5922721c57"
Expand Down Expand Up @@ -1905,6 +1943,13 @@
fast-url-parser "^1.1.3"
tslib "^2.3.1"

"@whatwg-node/promise-helpers@^1.0.0":
version "1.3.2"
resolved "https://registry.yarnpkg.com/@whatwg-node/promise-helpers/-/promise-helpers-1.3.2.tgz#3b54987ad6517ef6db5920c66a6f0dada606587d"
integrity sha512-Nst5JdK47VIl9UcGwtv2Rcgyn5lWtZ0/mhRQ4G8NN2isxpq2TO30iqHzmwoJycjWuyUfg3GFXqP/gFHXeV57IA==
dependencies:
tslib "^2.6.3"

"@xtuc/ieee754@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790"
Expand Down Expand Up @@ -3053,6 +3098,13 @@ cross-fetch@^3.1.5:
dependencies:
node-fetch "^2.6.12"

cross-inspect@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/cross-inspect/-/cross-inspect-1.0.1.tgz#15f6f65e4ca963cf4cc1a2b5fef18f6ca328712b"
integrity sha512-Pcw1JTvZLSJH83iiGWt6fRcT+BjZlCDRVwYLbUcHzv/CRpB7r0MlSrGbIyQvVSNyGnbt7G4AXuyCiDR3POvZ1A==
dependencies:
tslib "^2.4.0"

cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
Expand Down Expand Up @@ -3368,6 +3420,11 @@ dset@^3.1.2:
resolved "https://registry.yarnpkg.com/dset/-/dset-3.1.2.tgz#89c436ca6450398396dc6538ea00abc0c54cd45a"
integrity sha512-g/M9sqy3oHe477Ar4voQxWtaPIFw1jTdKZuomOjhCcBx9nHUNn0pu6NopuFFrTh/TRZIKEj+76vLWFu9BNKk+Q==

dset@^3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/dset/-/dset-3.1.4.tgz#f8eaf5f023f068a036d08cd07dc9ffb7d0065248"
integrity sha512-2QF/g9/zTaPDc3BjNcVTGoBbXBgYfMTTceLaYcFJ/W9kggFUkhxD/hMEeuLKbugyef9SqAx8cpgwlIP/jinUTA==

ee-first@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
Expand Down Expand Up @@ -4027,7 +4084,7 @@ fast-glob@^3.2.9:
merge2 "^1.3.0"
micromatch "^4.0.4"

fast-json-stable-stringify@^2.0.0:
fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
Expand Down Expand Up @@ -7946,6 +8003,11 @@ tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==

tslib@^2.6.3:
version "2.8.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==

tslib@~2.4.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e"
Expand Down
Loading