File upload functionality for own interiors (#39)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { EXPIRES_DEFAULT_SECS, getSignedPutObjectUrl } from '../s3';
|
||||
import {
|
||||
SignedUploadURL,
|
||||
SignedUploadURLInput,
|
||||
} from '../types/file-upload-types';
|
||||
import * as CONFIG from '../config';
|
||||
|
||||
async function getSignedFileUploadURL(
|
||||
_,
|
||||
args: SignedUploadURLInput,
|
||||
__,
|
||||
): Promise<SignedUploadURL> {
|
||||
const config = args.config;
|
||||
const bucket = CONFIG.uploadBucket;
|
||||
|
||||
const url = await getSignedPutObjectUrl(
|
||||
bucket,
|
||||
config.key,
|
||||
config.contentType,
|
||||
);
|
||||
return {
|
||||
url: url,
|
||||
key: config.key,
|
||||
bucket: bucket,
|
||||
expires: EXPIRES_DEFAULT_SECS,
|
||||
};
|
||||
}
|
||||
|
||||
export const imagesQueryTypeDefs = {
|
||||
signedFileUploadURL: getSignedFileUploadURL,
|
||||
};
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
|
||||
import { DateTimeResolver, DateResolver, JSONResolver } from 'graphql-scalars';
|
||||
import { interiorsQueryTypeDefs, interiorTypeDefs } from './interiors-resolver';
|
||||
import { imagesQueryTypeDefs } from './file-upload-resolvers';
|
||||
const resolvers = {
|
||||
Query: {
|
||||
...orderQueryTypeDefs,
|
||||
@@ -27,6 +28,7 @@ const resolvers = {
|
||||
...keywordsQueryTypeDefs,
|
||||
...marketsQueryTypeDefs,
|
||||
...interiorsQueryTypeDefs,
|
||||
...imagesQueryTypeDefs,
|
||||
},
|
||||
Mutation: {
|
||||
...productMutationTypeDefs,
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
ProductListResult,
|
||||
ProductsFilterInput,
|
||||
} from '../types/product-types';
|
||||
import * as CONFIG from '../config';
|
||||
import { CategoryAPI } from '../datasources/category-api';
|
||||
import { Category } from '../types/category-types';
|
||||
import { KeywordAPI } from '../datasources/keyword-api';
|
||||
@@ -11,6 +12,7 @@ import { Keyword } from '../types/keyword-types';
|
||||
import { MarketLocaleAPI } from '../datasources/market-locale-api';
|
||||
import { InteriorAPI } from '../datasources/interior-api';
|
||||
import { InteriorsLambdaAPI } from '../datasources/interiors-lambda-api';
|
||||
import { IdNumberResult } from '../types/types';
|
||||
|
||||
const ProductBlacklist = {
|
||||
async market(parent, _args, { dataSources }) {
|
||||
@@ -127,6 +129,16 @@ export const productMutationTypeDefs = {
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
async addOwnInteriorToPrintProduct(
|
||||
_,
|
||||
{ printId, uploadedS3Key },
|
||||
{ dataSources },
|
||||
): Promise<IdNumberResult> {
|
||||
return (<InteriorAPI>dataSources.interiorApi).addOwnUploadToPrintId(
|
||||
printId,
|
||||
uploadedS3Key,
|
||||
);
|
||||
},
|
||||
async productWallpaperType(
|
||||
_,
|
||||
{ productId, wallpaperTypes },
|
||||
|
||||
Reference in New Issue
Block a user