-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmediafileResolver.ts
57 lines (56 loc) · 1.46 KB
/
mediafileResolver.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { Resolvers } from "../../generated-types/type-defs";
import { ContextValue } from "base-graphql";
export const mediafileResolver: Resolvers<ContextValue> = {
Query: {
getMediafile: async (_source, { mediafileId }, { dataSources }) => {
return await dataSources.CollectionAPI.getMediaFile(
mediafileId as string
);
},
},
Mutation: {
patchMediaFileMetadata: async (
_source,
{ MediafileId, MediaFileMetadata },
{ dataSources }
) => {
return dataSources.CollectionAPI.patchMetaDataMediaFile(
MediafileId,
MediaFileMetadata
);
},
getAssetsRelationedWithMediafFile: async (
_source,
{ mediaFileId },
{ dataSources }
) => {
return dataSources.CollectionAPI.getAssetsRelationedWithMediafFile(
mediaFileId
);
},
},
MediaFile: {
isPublic: async (parent: any, _args, { dataSources }) => {
let result = false;
try {
if (
parent.metadata.filter(
(metaDataItem: { key: string }) =>
metaDataItem.key === "publication_status"
)[0]
) {
result =
parent.metadata.filter(
(metaDataItem: { key: string }) =>
metaDataItem.key === "publication_status"
)[0].value === "publiek";
} else {
result = false;
}
} catch (e) {
result = false;
}
return result;
},
},
};