File size: 571 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// @flow
import { isAuthedResolver } from '../../utils/permissions';
import { uploadImage } from '../../utils/file-storage';
import type { EntityTypes } from 'shared/types';
import type { FileUpload } from 'shared/types';
import { signImageUrl } from 'shared/imgix';

type Args = {
  input: {
    image: FileUpload,
    type: EntityTypes,
    id?: string,
  },
};

export default isAuthedResolver(async (_: void, { input }: Args) => {
  const { image, type, id } = input;
  const url = await uploadImage(image, type, id || 'draft');
  return await signImageUrl(url);
});