Product info mutation (#14)
* Add mutation for product info * Upgrade to apollo 3
This commit is contained in:
Generated
+12281
-562
File diff suppressed because it is too large
Load Diff
+7
-7
@@ -11,12 +11,12 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"apollo-datasource": "^0.9.0",
|
||||
"apollo-datasource-rest": "^3.0.0",
|
||||
"apollo-server": "^2.25.2",
|
||||
"apollo-datasource": "^3.1.0",
|
||||
"apollo-datasource-rest": "^3.2.0",
|
||||
"apollo-server": "^3.3.0",
|
||||
"async-redis": "^2.0.0",
|
||||
"axios": "^0.21.1",
|
||||
"datasource-sql": "^1.4.1",
|
||||
"datasource-sql": "^1.5.0",
|
||||
"dotenv": "^10.0.0",
|
||||
"graphql": "^15.5.1",
|
||||
"graphql-scalars": "^1.10.0",
|
||||
@@ -24,12 +24,12 @@
|
||||
"jwk-to-pem": "^2.0.5",
|
||||
"knex-stringcase": "^1.4.5",
|
||||
"nodemon": "^2.0.12",
|
||||
"pg": "^8.6.0",
|
||||
"pg": "^8.7.1",
|
||||
"pg-hstore": "^2.3.4",
|
||||
"prettier": "^2.3.2",
|
||||
"stringcase": "^4.3.1",
|
||||
"ts-node": "^10.1.0",
|
||||
"typescript": "^4.3.5",
|
||||
"ts-node": "^10.2.1",
|
||||
"typescript": "^4.4.2",
|
||||
"util": "^0.12.4",
|
||||
"validator": "^13.6.0"
|
||||
},
|
||||
|
||||
@@ -5,4 +5,15 @@ export const dbConfig = {
|
||||
min: 1,
|
||||
max: 10,
|
||||
},
|
||||
stringcase: [
|
||||
'snakecase',
|
||||
(output) => {
|
||||
if (output === 'product_products') {
|
||||
return 'product-products';
|
||||
} else if (output === 'order_rows_fields') {
|
||||
return 'order-rows_fields';
|
||||
}
|
||||
return output;
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ export class InteriorAPI extends BaseSQLDataSource {
|
||||
case 'landscape':
|
||||
return Orientation[Orientation.LANDSCAPE];
|
||||
case 'standing':
|
||||
return Orientation[Orientation.PORTRAIT];
|
||||
return Orientation[Orientation.STANDING];
|
||||
case 'square':
|
||||
return Orientation[Orientation.SQUARE];
|
||||
default:
|
||||
|
||||
@@ -10,11 +10,12 @@ import {
|
||||
ProductWallpaperType,
|
||||
ProductFields,
|
||||
Orientation,
|
||||
ProductsFilter,
|
||||
ProductsFilterInput,
|
||||
ProductInfoInput,
|
||||
} from '../types/product-types';
|
||||
import { Maybe } from '../types/types';
|
||||
import { convertToPossibleType } from './utils';
|
||||
import { isNode } from 'graphql/language/ast';
|
||||
|
||||
const MINUTE = 60;
|
||||
|
||||
@@ -88,7 +89,7 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
return Orientation[Orientation.LANDSCAPE];
|
||||
}
|
||||
if (fields.width < fields.height) {
|
||||
return Orientation[Orientation.PORTRAIT];
|
||||
return Orientation[Orientation.STANDING];
|
||||
}
|
||||
return Orientation[Orientation.SQUARE];
|
||||
}
|
||||
@@ -101,7 +102,6 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
row.fields = this.getProductFields(row);
|
||||
row.designerId = row.designerid;
|
||||
row.orientation = this.getOrientation(row.fields);
|
||||
row.fields_json = row.fields;
|
||||
return row;
|
||||
}
|
||||
|
||||
@@ -159,4 +159,45 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
|
||||
return ids.map(async (id) => this.getProduct(id));
|
||||
}
|
||||
|
||||
// mutations below
|
||||
private async updateProductField(
|
||||
productId: number,
|
||||
field: string,
|
||||
value: string,
|
||||
): Promise<void> {
|
||||
return this.knex.raw(
|
||||
/* sql */ `
|
||||
UPDATE "product-products_fields" SET value = ?
|
||||
WHERE productid = ?
|
||||
AND fieldid = (SELECT fieldid FROM "product-fields" WHERE field = ?)`,
|
||||
[value, productId, field],
|
||||
);
|
||||
}
|
||||
|
||||
async updateProductInfo(
|
||||
productId: number,
|
||||
info: ProductInfoInput,
|
||||
): Promise<any[]> {
|
||||
const promises = [];
|
||||
promises.push(
|
||||
this.knex
|
||||
.table('product-products')
|
||||
.update({
|
||||
path: info.path,
|
||||
browsable: info.browsable ? 1 : 0,
|
||||
visible: info.visible ? 1 : 0,
|
||||
designerid: info.designerId,
|
||||
ref1: info.ref1,
|
||||
ref2: info.ref2,
|
||||
ref3: info.ref3,
|
||||
})
|
||||
.where({ productid: productId }),
|
||||
this.updateProductField(productId, 'artNo', info.artNo),
|
||||
this.updateProductField(productId, 'name', info.name),
|
||||
this.updateProductField(productId, 'batch', info.batch),
|
||||
this.updateProductField(productId, 'copyright', info.copyright),
|
||||
);
|
||||
return Promise.all(promises);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { ProductsFilter, ProductsFilterInput } from '../../types/product-types';
|
||||
import { Maybe } from '../../types/types';
|
||||
import { ProductsFilterInput } from '../../types/product-types';
|
||||
|
||||
// Get syntax highlighting with vscode by installing "Comment tagged templates2
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ function isBoolean(n: any) {
|
||||
}
|
||||
|
||||
export function convertToPossibleType(n: any) {
|
||||
if (isBoolean(n)) return Boolean('false');
|
||||
if ('' === n) return '';
|
||||
if (isBoolean(n)) return Boolean(n);
|
||||
if (isNumeric(n)) return Number(n);
|
||||
return n;
|
||||
}
|
||||
|
||||
+7
-3
@@ -4,7 +4,7 @@ dotenv.config();
|
||||
import { ApolloServer, AuthenticationError } from 'apollo-server';
|
||||
import knexStringcase from 'knex-stringcase';
|
||||
import { dbConfig } from './config';
|
||||
import { typeDefs } from './schema';
|
||||
|
||||
import resolvers from './resolvers';
|
||||
import { OrderAPI } from './datasources/order-api';
|
||||
import { ProductAPI } from './datasources/product-api';
|
||||
@@ -16,6 +16,11 @@ import { ImageServerApi } from './datasources/imageserver-api';
|
||||
import { InteriorAPI } from './datasources/interior-api';
|
||||
|
||||
import { verifyToken } from './cognito/cognito-client';
|
||||
import { readFileSync } from 'fs';
|
||||
const path = require('path');
|
||||
const typeDefs = readFileSync(
|
||||
path.join(__dirname, './schema.graphql'),
|
||||
).toString('utf-8');
|
||||
|
||||
// Should we convert columns?
|
||||
const knexConfig = knexStringcase(dbConfig);
|
||||
@@ -64,8 +69,7 @@ async function main() {
|
||||
resolvers,
|
||||
dataSources,
|
||||
context,
|
||||
introspection: true,
|
||||
playground: true,
|
||||
introspection: false,
|
||||
});
|
||||
|
||||
await server.listen();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { IResolverObject } from 'graphql-tools';
|
||||
import { CategoryAPI } from '../datasources/category-api';
|
||||
import { ProductAPI } from '../datasources/product-api';
|
||||
|
||||
const Category: IResolverObject = {
|
||||
const Category = {
|
||||
async products({ id }, _args, { dataSources }) {
|
||||
return (<ProductAPI>dataSources.productApi).getCategoryProducts(id);
|
||||
},
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { IResolverObject } from 'graphql-tools';
|
||||
import { DesignerAPI } from '../datasources/designer-api';
|
||||
import { OrderAPI } from '../datasources/order-api';
|
||||
import { GeneralInput } from '../types/types';
|
||||
|
||||
const Designer: IResolverObject = {
|
||||
const Designer = {
|
||||
async orderRows({ id }, input: GeneralInput, { dataSources }) {
|
||||
return (<OrderAPI>dataSources.orderApi).getOrderRowsByDesignerId(id, input);
|
||||
},
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { IResolverObject } from 'graphql-tools';
|
||||
import { InteriorAPI } from '../datasources/interior-api';
|
||||
import { InteriorsFilterInput } from '../types/interior-types';
|
||||
|
||||
const Interior: IResolverObject = {};
|
||||
const Interior = {};
|
||||
|
||||
async function getInteriors(_, args: InteriorsFilterInput, { dataSources }) {
|
||||
return (<InteriorAPI>dataSources.interiorApi).getInteriors(args.filter);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { IResolverObject } from 'graphql-tools';
|
||||
import { KeywordAPI } from '../datasources/keyword-api';
|
||||
import { ProductAPI } from '../datasources/product-api';
|
||||
|
||||
const Keyword: IResolverObject = {
|
||||
const Keyword = {
|
||||
async products({ id }, _args, { dataSources }) {
|
||||
return (<ProductAPI>dataSources.productApi).getKeywordProducts(id);
|
||||
},
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { IResolverObject } from 'graphql-tools';
|
||||
import { MarketLocaleAPI } from '../datasources/market-locale-api';
|
||||
|
||||
const Market: IResolverObject = {};
|
||||
const Market = {};
|
||||
|
||||
async function getMarkets(_, _args, { dataSources }) {
|
||||
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarkets();
|
||||
@@ -11,7 +10,7 @@ async function getMarket(_, { name }, { dataSources }) {
|
||||
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarketByName(name);
|
||||
}
|
||||
|
||||
const Locale: IResolverObject = {};
|
||||
const Locale = {};
|
||||
|
||||
async function getLocales(_, _args, { dataSources }) {
|
||||
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getLocales();
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { IResolverObject } from 'graphql-tools';
|
||||
import { MarketLocaleAPI } from '../datasources/market-locale-api';
|
||||
import { OrderAPI } from '../datasources/order-api';
|
||||
import { OrdersResult } from '../types/order-types';
|
||||
import { GeneralInput } from '../types/types';
|
||||
|
||||
const ContactInformation: IResolverObject = {
|
||||
const ContactInformation = {
|
||||
// (parent, args, ctx, info)
|
||||
async address({ addressId }, _args, { dataSources }) {
|
||||
return (<OrderAPI>dataSources.orderApi).getAddress(addressId);
|
||||
},
|
||||
};
|
||||
|
||||
const Order: IResolverObject = {
|
||||
const Order = {
|
||||
async rows({ id }, _args, { dataSources }) {
|
||||
return (<OrderAPI>dataSources.orderApi).getOrderRowsByOrderId(id);
|
||||
},
|
||||
@@ -27,7 +26,7 @@ const Order: IResolverObject = {
|
||||
},
|
||||
};
|
||||
|
||||
const OrderRow: IResolverObject = {
|
||||
const OrderRow = {
|
||||
async order(parent, _args, { dataSources }) {
|
||||
return (<OrderAPI>dataSources.orderApi).getOrderById(parent.orderId);
|
||||
},
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { IResolverObject } from 'graphql-tools';
|
||||
import { ProductAPI } from '../datasources/product-api';
|
||||
import {
|
||||
Product,
|
||||
@@ -12,7 +11,7 @@ import { Keyword } from '../types/keyword-types';
|
||||
import { MarketLocaleAPI } from '../datasources/market-locale-api';
|
||||
import { InteriorAPI } from '../datasources/interior-api';
|
||||
|
||||
const ProductBlacklist: IResolverObject = {
|
||||
const ProductBlacklist = {
|
||||
async market(parent, _args, { dataSources }) {
|
||||
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarketById(
|
||||
parent.marketId,
|
||||
@@ -20,7 +19,7 @@ const ProductBlacklist: IResolverObject = {
|
||||
},
|
||||
};
|
||||
|
||||
const Product: IResolverObject = {
|
||||
const Product = {
|
||||
// (parent, args, ctx, info)
|
||||
async categories({ id }, _args, { dataSources }): Promise<Array<Category>> {
|
||||
return (<CategoryAPI>dataSources.categoryApi).getProductCategories(id);
|
||||
@@ -39,7 +38,7 @@ const Product: IResolverObject = {
|
||||
},
|
||||
};
|
||||
|
||||
const PrintProduct: IResolverObject = {
|
||||
const PrintProduct = {
|
||||
async interiors({ id }, _args, { dataSources }) {
|
||||
return (<InteriorAPI>dataSources.interiorApi).getPrintProductInteriors(id);
|
||||
},
|
||||
@@ -78,10 +77,14 @@ export const productQueryTypeDefs = {
|
||||
product: getProduct,
|
||||
};
|
||||
|
||||
// Mutations below, embryo stage
|
||||
|
||||
///////////////////
|
||||
// Mutations below
|
||||
export const productMutationTypeDefs = {
|
||||
addKeyword(_, { productId, keywordId }, { dataSources }) {
|
||||
return { result: 'OK' };
|
||||
async productInfo(_, { productId, info }, { dataSources }) {
|
||||
await (<ProductAPI>dataSources.productApi).updateProductInfo(
|
||||
productId,
|
||||
info,
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -0,0 +1,387 @@
|
||||
"""
|
||||
Photowall Graphql Schema
|
||||
"""
|
||||
scalar DateTime
|
||||
scalar Date
|
||||
scalar JSON
|
||||
|
||||
type Query {
|
||||
orders(pagination: PaginationInput!, filter: DateFilterInput!): OrdersResult
|
||||
order(id: ID!): Order
|
||||
products(
|
||||
pagination: PaginationInput!
|
||||
filter: ProductsFilterInput!
|
||||
): ProductsResult
|
||||
product(id: Int!): Product
|
||||
categories: [Category]
|
||||
category(id: Int!): Category
|
||||
keywords: [Keyword]
|
||||
keyword(id: Int!): Keyword
|
||||
designers(limit: Int): [Designer]
|
||||
designer(id: Int!): Designer
|
||||
markets: [Market]
|
||||
market(name: String!): Market
|
||||
locales: [Locale]
|
||||
locale(value: String!): Locale
|
||||
interiors(filter: InteriorsFilterInput): [Interior]
|
||||
}
|
||||
|
||||
input PaginationInput {
|
||||
limit: Int!
|
||||
"""
|
||||
offset is not implemented yet and result will always return as if it was 0. Implement when needed.
|
||||
"""
|
||||
offset: Int
|
||||
}
|
||||
|
||||
input DateInput {
|
||||
from: Date!
|
||||
to: Date!
|
||||
}
|
||||
|
||||
input DateFilterInput {
|
||||
dates: DateInput
|
||||
}
|
||||
|
||||
input ProductsFilterInput {
|
||||
visible: Boolean
|
||||
browsable: Boolean
|
||||
}
|
||||
|
||||
type PaginationResult {
|
||||
total: Int!
|
||||
offset: Int!
|
||||
limit: Int!
|
||||
}
|
||||
|
||||
type OrdersResult {
|
||||
pagination: PaginationResult!
|
||||
items: [Order]
|
||||
}
|
||||
|
||||
type ProductsResult {
|
||||
pagination: PaginationResult!
|
||||
items: [Product]
|
||||
}
|
||||
|
||||
"""
|
||||
Only return valid interiors for product, type and orientation
|
||||
"""
|
||||
input InteriorsFilterInput {
|
||||
productId: Int!
|
||||
type: InteriorType!
|
||||
orientation: Orientation!
|
||||
}
|
||||
|
||||
type Market {
|
||||
id: ID!
|
||||
name: String!
|
||||
vat: Float!
|
||||
currency: String!
|
||||
priceAdjustment: Float!
|
||||
}
|
||||
|
||||
type Locale {
|
||||
id: ID!
|
||||
value: String!
|
||||
name: String!
|
||||
fallbackId: Int
|
||||
}
|
||||
|
||||
type Address {
|
||||
id: ID!
|
||||
firstname: String
|
||||
lastname: String
|
||||
recipientName: String
|
||||
companyname: String
|
||||
address1: String
|
||||
address2: String
|
||||
countryCode: String
|
||||
city: String
|
||||
zipcode: String
|
||||
stateCountyOrRegion: String
|
||||
}
|
||||
|
||||
type ContactInformation {
|
||||
email: String
|
||||
phone: String
|
||||
address: Address
|
||||
}
|
||||
|
||||
type Order {
|
||||
id: ID!
|
||||
inserted: DateTime!
|
||||
paid: Boolean!
|
||||
confirmed: Boolean!
|
||||
delivered: Boolean!
|
||||
newsletter: Boolean
|
||||
creditInvoice: Boolean
|
||||
canceled: Boolean
|
||||
reminder: Boolean
|
||||
deliveredDate: DateTime
|
||||
countryCode: String
|
||||
language: String
|
||||
deliveryCountryCode: String
|
||||
deliveryMethod: String
|
||||
deliveryPrice: String
|
||||
deliveryVat: Float
|
||||
customerType: String
|
||||
paymentType: String
|
||||
attention: String
|
||||
currency: String
|
||||
exchangeRate: Float
|
||||
exchangeRateEur: Float
|
||||
invoiceId: String
|
||||
contractCustomerId: Int
|
||||
vatNumber: String
|
||||
comment: String
|
||||
cancelsOrderId: Int
|
||||
cancelledByOrderId: Int
|
||||
orderlogId: Int
|
||||
resellerStore: String
|
||||
orderSum: Float
|
||||
klarnaOrderId: String
|
||||
pwintyId: Int
|
||||
email: String
|
||||
phone: String
|
||||
deliveryEmail: String
|
||||
deliveryPhone: String
|
||||
customerFirstname: String
|
||||
customerLastname: String
|
||||
customerEmail: String
|
||||
customerCellphone: String
|
||||
flyerIds: String
|
||||
billingInformation: ContactInformation
|
||||
deliveryInformation: ContactInformation
|
||||
billingAddressId: Int
|
||||
deliveryAddressId: Int
|
||||
"""
|
||||
pwinty needs to be updated with market being a subtype
|
||||
"""
|
||||
market: Market
|
||||
locale: Locale
|
||||
rows: [OrderRow]
|
||||
}
|
||||
|
||||
type OrderRow {
|
||||
id: ID!
|
||||
artNo: String
|
||||
code: String
|
||||
commission: Int
|
||||
commissionAmount: Float
|
||||
commissionResale: Int
|
||||
designer: String
|
||||
designerId: Int
|
||||
designerPath: String
|
||||
discountType: String
|
||||
discountValue: Float
|
||||
displayHeight: Float
|
||||
displayWidth: Float
|
||||
edge: String
|
||||
frameColor: String
|
||||
framed: Int
|
||||
group: ProductGroup
|
||||
height: Int
|
||||
imagedonotprint: Int
|
||||
imageprocessed: Int
|
||||
imageprocessingrejected: Int
|
||||
inserted: DateTime
|
||||
material: String
|
||||
measureUnit: String
|
||||
mirrored: Int
|
||||
modifier: String
|
||||
name: String
|
||||
noShipping: Boolean
|
||||
order: Order
|
||||
orderId: Int
|
||||
path: String
|
||||
price: Float
|
||||
printId: Int
|
||||
process: Boolean
|
||||
productGroup: String
|
||||
productId: Int
|
||||
pwintyImageId: Int
|
||||
pwintySku: String
|
||||
resolution: Int
|
||||
status: String
|
||||
type: String
|
||||
vat: Float
|
||||
weight: Int
|
||||
width: Int
|
||||
x: Float
|
||||
y: Float
|
||||
}
|
||||
|
||||
type Category {
|
||||
id: ID!
|
||||
name: String
|
||||
path: String
|
||||
pathNumeric: String
|
||||
isLeaf: Int
|
||||
depth: Int
|
||||
childCount: Int
|
||||
lft: Int
|
||||
rgt: Int
|
||||
products: [Product]
|
||||
}
|
||||
|
||||
type Product {
|
||||
id: ID!
|
||||
stockid: Int
|
||||
path: String!
|
||||
visible: Boolean!
|
||||
browsable: Boolean!
|
||||
inserted: DateTime!
|
||||
updated: DateTime
|
||||
printProducts: [PrintProduct]
|
||||
blacklisting: [ProductBlacklist]
|
||||
categories: [Category]
|
||||
designerId: Int
|
||||
designer: Designer
|
||||
keywords: [Keyword]
|
||||
ref1: String
|
||||
ref2: String
|
||||
ref3: String
|
||||
related: [Product]
|
||||
wallpaperTypes: [ProductWallpaperType]
|
||||
fields: ProductFields
|
||||
orientation: Orientation
|
||||
"""
|
||||
Will be single values return in later release
|
||||
"""
|
||||
type: [ProductType]
|
||||
# Below are for debug and will be removed soon
|
||||
fields_json: JSON
|
||||
}
|
||||
|
||||
type ProductFields {
|
||||
artNo: String!
|
||||
name: String!
|
||||
height: Int
|
||||
width: Int
|
||||
photowallResolution: Int
|
||||
canvasResolution: Int
|
||||
wallpaperResolution: Int
|
||||
copyright: String
|
||||
proportionsWarning: String
|
||||
marginWidthMax: Int
|
||||
marginWidthMin: Int
|
||||
marginHeightMax: Int
|
||||
marginHeightMin: Int
|
||||
focusXpoint: Float
|
||||
focusYpoint: Float
|
||||
focusXpoint2: Float
|
||||
focusYpoint2: Float
|
||||
batch: String
|
||||
imageResolution: Int
|
||||
printFileWidth: Int
|
||||
printFileHeight: Int
|
||||
printFileDpi: Int
|
||||
}
|
||||
|
||||
enum Orientation {
|
||||
UNKNOWN
|
||||
STANDING
|
||||
LANDSCAPE
|
||||
SQUARE
|
||||
}
|
||||
|
||||
enum ProductGroup {
|
||||
PHOTO_WALLPAPER
|
||||
CANVAS
|
||||
WALLPAPER
|
||||
OLD_REMOVED
|
||||
DO_IT_YOURSELF_FRAME
|
||||
DESIGNER_WALLPAPER
|
||||
POSTER
|
||||
FRAMED_PRINT
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
enum ProductType {
|
||||
UNKNOWN
|
||||
PHOTO
|
||||
ILLUSTRATION
|
||||
}
|
||||
|
||||
enum ProductWallpaperType {
|
||||
WALLMURAL
|
||||
DESIGN
|
||||
}
|
||||
|
||||
type ProductBlacklist {
|
||||
id: ID!
|
||||
groupId: Int!
|
||||
group: ProductGroup!
|
||||
market: Market!
|
||||
inserted: DateTime!
|
||||
updated: DateTime!
|
||||
}
|
||||
|
||||
type PrintProduct {
|
||||
id: ID!
|
||||
groupId: Int!
|
||||
group: ProductGroup!
|
||||
inserted: DateTime!
|
||||
updated: DateTime
|
||||
interiors: [Interior]
|
||||
}
|
||||
|
||||
enum InteriorType {
|
||||
WALLPAPER
|
||||
PAINTING
|
||||
POSTER
|
||||
FRAMED_PRINT
|
||||
}
|
||||
|
||||
type Interior {
|
||||
"""
|
||||
room id
|
||||
"""
|
||||
id: ID!
|
||||
roomName: String
|
||||
position: Int
|
||||
roomType: String
|
||||
uri: String
|
||||
roomNumber: Int
|
||||
type: InteriorType
|
||||
orientation: Orientation
|
||||
}
|
||||
|
||||
type Designer {
|
||||
id: ID!
|
||||
name: String
|
||||
path: String
|
||||
orderRows(pagination: PaginationInput!, filter: DateFilterInput): [OrderRow]
|
||||
}
|
||||
|
||||
enum KeywordType {
|
||||
NOT_SET
|
||||
COLOR
|
||||
}
|
||||
|
||||
type Keyword {
|
||||
id: ID!
|
||||
value: String!
|
||||
type: KeywordType
|
||||
products: [Product]
|
||||
}
|
||||
|
||||
# Mutations below
|
||||
input ProductInfoInput {
|
||||
name: String!
|
||||
artNo: String!
|
||||
path: String!
|
||||
batch: String!
|
||||
copyright: String!
|
||||
ref1: String!
|
||||
ref2: String!
|
||||
ref3: String!
|
||||
designerId: Int!
|
||||
browsable: Boolean!
|
||||
visible: Boolean!
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
productInfo(productId: Int!, info: ProductInfoInput!): Product
|
||||
}
|
||||
-449
@@ -1,449 +0,0 @@
|
||||
import { gql } from 'apollo-server';
|
||||
|
||||
const typeDefs = gql`
|
||||
scalar DateTime
|
||||
scalar Date
|
||||
scalar JSON
|
||||
|
||||
type Query {
|
||||
orders(pagination: PaginationInput!, filter: DateFilterInput!): OrdersResult
|
||||
order(id: ID!): Order
|
||||
products(
|
||||
pagination: PaginationInput!
|
||||
filter: ProductsFilterInput!
|
||||
): ProductsResult
|
||||
product(id: Int!): Product
|
||||
categories: [Category]
|
||||
category(id: Int!): Category
|
||||
keywords: [Keyword]
|
||||
keyword(id: Int!): Keyword
|
||||
designers(limit: Int): [Designer]
|
||||
designer(id: Int!): Designer
|
||||
markets: [Market]
|
||||
market(name: String!): Market
|
||||
locales: [Locale]
|
||||
locale(value: String!): Locale
|
||||
interiors(filter: InteriorsFilterInput): [Interior]
|
||||
}
|
||||
|
||||
input PaginationInput {
|
||||
limit: Int!
|
||||
"""
|
||||
offset is not implemented yet and result will always return as if it was 0. Implement when needed.
|
||||
"""
|
||||
offset: Int
|
||||
}
|
||||
|
||||
input DateInput {
|
||||
from: Date!
|
||||
to: Date!
|
||||
}
|
||||
|
||||
input DateFilterInput {
|
||||
dates: DateInput
|
||||
}
|
||||
|
||||
input ProductsFilterInput {
|
||||
visible: Boolean
|
||||
browsable: Boolean
|
||||
}
|
||||
|
||||
type PaginationResult {
|
||||
total: Int!
|
||||
offset: Int!
|
||||
limit: Int!
|
||||
}
|
||||
|
||||
type OrdersResult {
|
||||
pagination: PaginationResult!
|
||||
items: [Order]
|
||||
}
|
||||
|
||||
type ProductsResult {
|
||||
pagination: PaginationResult!
|
||||
items: [Product]
|
||||
}
|
||||
|
||||
"""
|
||||
Only return valid interiors for product, type and orientation
|
||||
"""
|
||||
input InteriorsFilterInput {
|
||||
productId: Int!
|
||||
type: InteriorType!
|
||||
orientation: Orientation!
|
||||
}
|
||||
|
||||
type Market {
|
||||
id: ID!
|
||||
name: String!
|
||||
vat: Float!
|
||||
currency: String!
|
||||
priceAdjustment: Float!
|
||||
}
|
||||
|
||||
type Locale {
|
||||
id: ID!
|
||||
value: String!
|
||||
name: String!
|
||||
fallbackId: Int
|
||||
}
|
||||
|
||||
type Address {
|
||||
id: ID!
|
||||
firstname: String
|
||||
lastname: String
|
||||
recipientName: String
|
||||
companyname: String
|
||||
address1: String
|
||||
address2: String
|
||||
countryCode: String
|
||||
city: String
|
||||
zipcode: String
|
||||
stateCountyOrRegion: String
|
||||
}
|
||||
|
||||
type ContactInformation {
|
||||
email: String
|
||||
phone: String
|
||||
address: Address
|
||||
}
|
||||
|
||||
type Order {
|
||||
id: ID!
|
||||
inserted: DateTime!
|
||||
paid: Boolean!
|
||||
confirmed: Boolean!
|
||||
delivered: Boolean!
|
||||
newsletter: Boolean
|
||||
creditInvoice: Boolean
|
||||
canceled: Boolean
|
||||
reminder: Boolean
|
||||
deliveredDate: DateTime
|
||||
countryCode: String
|
||||
language: String
|
||||
deliveryCountryCode: String
|
||||
deliveryMethod: String
|
||||
deliveryPrice: String
|
||||
deliveryVat: Float
|
||||
customerType: String
|
||||
paymentType: String
|
||||
attention: String
|
||||
currency: String
|
||||
exchangeRate: Float
|
||||
exchangeRateEur: Float
|
||||
invoiceId: String
|
||||
contractCustomerId: Int
|
||||
vatNumber: String
|
||||
comment: String
|
||||
cancelsOrderId: Int
|
||||
cancelledByOrderId: Int
|
||||
orderlogId: Int
|
||||
resellerStore: String
|
||||
orderSum: Float
|
||||
klarnaOrderId: String
|
||||
pwintyId: Int
|
||||
email: String
|
||||
phone: String
|
||||
deliveryEmail: String
|
||||
deliveryPhone: String
|
||||
customerFirstname: String
|
||||
customerLastname: String
|
||||
customerEmail: String
|
||||
customerCellphone: String
|
||||
flyerIds: String
|
||||
billingInformation: ContactInformation
|
||||
deliveryInformation: ContactInformation
|
||||
billingAddressId: Int
|
||||
deliveryAddressId: Int
|
||||
"""
|
||||
pwinty needs to be updated with market being a subtype
|
||||
"""
|
||||
market: Market
|
||||
locale: Locale
|
||||
rows: [OrderRow]
|
||||
}
|
||||
|
||||
type OrderRow {
|
||||
id: ID!
|
||||
artNo: String
|
||||
code: String
|
||||
commission: Int
|
||||
commissionAmount: Float
|
||||
commissionResale: Int
|
||||
designer: String
|
||||
designerId: Int
|
||||
designerPath: String
|
||||
discountType: String
|
||||
discountValue: Float
|
||||
displayHeight: Float
|
||||
displayWidth: Float
|
||||
edge: String
|
||||
frameColor: String
|
||||
framed: Int
|
||||
group: ProductGroup
|
||||
height: Int
|
||||
imagedonotprint: Int
|
||||
imageprocessed: Int
|
||||
imageprocessingrejected: Int
|
||||
inserted: DateTime
|
||||
material: String
|
||||
measureUnit: String
|
||||
mirrored: Int
|
||||
modifier: String
|
||||
name: String
|
||||
noShipping: Boolean
|
||||
order: Order
|
||||
orderId: Int
|
||||
path: String
|
||||
price: Float
|
||||
printId: Int
|
||||
process: Boolean
|
||||
productGroup: String
|
||||
productId: Int
|
||||
pwintyImageId: Int
|
||||
pwintySku: String
|
||||
resolution: Int
|
||||
status: String
|
||||
type: String
|
||||
vat: Float
|
||||
weight: Int
|
||||
width: Int
|
||||
x: Float
|
||||
y: Float
|
||||
}
|
||||
|
||||
type Category {
|
||||
id: ID!
|
||||
name: String
|
||||
path: String
|
||||
pathNumeric: String
|
||||
isLeaf: Int
|
||||
depth: Int
|
||||
childCount: Int
|
||||
lft: Int
|
||||
rgt: Int
|
||||
products: [Product]
|
||||
}
|
||||
|
||||
type Product {
|
||||
id: ID!
|
||||
stockid: Int
|
||||
path: String!
|
||||
visible: Boolean!
|
||||
browsable: Boolean!
|
||||
inserted: DateTime!
|
||||
updated: DateTime
|
||||
printProducts: [PrintProduct]
|
||||
blacklisting: [ProductBlacklist]
|
||||
categories: [Category]
|
||||
designerId: Int
|
||||
designer: Designer
|
||||
keywords: [Keyword]
|
||||
ref1: String
|
||||
ref2: String
|
||||
ref3: String
|
||||
related: [Product]
|
||||
wallpaperTypes: [ProductWallpaperType]
|
||||
fields: ProductFields
|
||||
orientation: Orientation
|
||||
"""
|
||||
Will be single values return in later release
|
||||
"""
|
||||
type: [ProductType]
|
||||
# Below are for debug and will be removed soon
|
||||
fields_json: JSON
|
||||
}
|
||||
|
||||
type ProductFields {
|
||||
artNo: String!
|
||||
name: String!
|
||||
height: Int
|
||||
width: Int
|
||||
photowallResolution: Int
|
||||
canvasResolution: Int
|
||||
wallpaperResolution: Int
|
||||
copyright: String
|
||||
proportionsWarning: String
|
||||
marginWidthMax: Int
|
||||
marginWidthMin: Int
|
||||
marginHeightMax: Int
|
||||
marginHeightMin: Int
|
||||
focusXpoint: Float
|
||||
focusYpoint: Float
|
||||
focusXpoint2: Float
|
||||
focusYpoint2: Float
|
||||
batch: String
|
||||
imageResolution: Int
|
||||
printFileWidth: Int
|
||||
printFileHeight: Int
|
||||
printFileDpi: Int
|
||||
}
|
||||
|
||||
enum Orientation {
|
||||
UNKNOWN
|
||||
PORTRAIT
|
||||
LANDSCAPE
|
||||
SQUARE
|
||||
}
|
||||
|
||||
enum ProductGroup {
|
||||
PHOTO_WALLPAPER
|
||||
CANVAS
|
||||
WALLPAPER
|
||||
OLD_REMOVED
|
||||
DO_IT_YOURSELF_FRAME
|
||||
DESIGNER_WALLPAPER
|
||||
POSTER
|
||||
FRAMED_PRINT
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
enum ProductType {
|
||||
UNKNOWN
|
||||
PHOTO
|
||||
ILLUSTRATION
|
||||
}
|
||||
|
||||
enum ProductWallpaperType {
|
||||
WALLMURAL
|
||||
DESIGN
|
||||
}
|
||||
|
||||
type ProductBlacklist {
|
||||
id: ID!
|
||||
groupId: Int!
|
||||
group: ProductGroup!
|
||||
market: Market!
|
||||
inserted: DateTime!
|
||||
updated: DateTime!
|
||||
}
|
||||
|
||||
type PrintProduct {
|
||||
id: ID!
|
||||
groupId: Int!
|
||||
group: ProductGroup!
|
||||
inserted: DateTime!
|
||||
updated: DateTime
|
||||
interiors: [Interior]
|
||||
}
|
||||
|
||||
enum InteriorType {
|
||||
WALLPAPER
|
||||
PAINTING
|
||||
POSTER
|
||||
FRAMED_PRINT
|
||||
}
|
||||
|
||||
type Interior {
|
||||
"""
|
||||
room id
|
||||
"""
|
||||
id: ID!
|
||||
roomName: String
|
||||
position: Int
|
||||
roomType: String
|
||||
uri: String
|
||||
roomNumber: Int
|
||||
type: InteriorType
|
||||
orientation: Orientation
|
||||
}
|
||||
|
||||
type Designer {
|
||||
id: ID!
|
||||
name: String
|
||||
path: String
|
||||
orderRows(pagination: PaginationInput!, filter: DateFilterInput): [OrderRow]
|
||||
}
|
||||
|
||||
enum KeywordType {
|
||||
NOT_SET
|
||||
COLOR
|
||||
}
|
||||
|
||||
type Keyword {
|
||||
id: ID!
|
||||
value: String!
|
||||
type: KeywordType
|
||||
products: [Product]
|
||||
}
|
||||
|
||||
# Mutations below
|
||||
type Mutation {
|
||||
addKeyword(productId: Int!, keywordId: Int!): MutationResult
|
||||
}
|
||||
|
||||
type MutationResult {
|
||||
result: String!
|
||||
}
|
||||
`;
|
||||
|
||||
export { typeDefs };
|
||||
|
||||
/*
|
||||
orderrows example
|
||||
{
|
||||
printId: '73963',
|
||||
productId: '54192',
|
||||
group: 'photo-wallpaper',
|
||||
type: 'scaling',
|
||||
artNo: 'e50075',
|
||||
path: 'flora-hysterica-4',
|
||||
name: 'Flora Hysterica 4',
|
||||
price: '587.092480',
|
||||
width: '640',
|
||||
height: '260',
|
||||
x: '0.000000',
|
||||
y: '0.135133',
|
||||
weight: '1',
|
||||
designer: 'martin-bergstrom',
|
||||
designerId: '201',
|
||||
commission: '0',
|
||||
commissionResale: '0',
|
||||
status: 'print',
|
||||
process: 'true',
|
||||
vat: '1.210000',
|
||||
commissionAmount: '0.000000',
|
||||
framed: '0',
|
||||
mirrored: '0',
|
||||
edge: '0',
|
||||
imageprocessed: 'true',
|
||||
imageprocessingrejected: 'false',
|
||||
resolution: '150',
|
||||
imagedonotprint: 'false',
|
||||
material: 'premium-wallpaper',
|
||||
discountType: '%',
|
||||
discountValue: '25',
|
||||
measureUnit: 'cm',
|
||||
displayWidth: '640',
|
||||
displayHeight: '260',
|
||||
designerPath: 'martin-bergstrom',
|
||||
productGroup: 'photo-wallpaper',
|
||||
id: 1559849,
|
||||
orderId: 588274,
|
||||
inserted: 2021-02-04T09:58:11.243Z
|
||||
},
|
||||
{
|
||||
type: '%',
|
||||
name: 'Influencer 2021 IT',
|
||||
price: '-150.826446',
|
||||
vat: '1.210000',
|
||||
modifier: 'discount',
|
||||
code: 'mynameiseleonora25',
|
||||
noShipping: 'False',
|
||||
id: 1559850,
|
||||
orderId: 588274,
|
||||
inserted: 2021-02-04T09:58:11.243Z
|
||||
}
|
||||
|
||||
|
||||
types:
|
||||
"doityourselfframe"
|
||||
"fixed"
|
||||
"tiling"
|
||||
"gift-voucher"
|
||||
"custom"
|
||||
"scaling"
|
||||
"%"
|
||||
"stock"
|
||||
|
||||
*/
|
||||
@@ -1,5 +1,20 @@
|
||||
import { PaginationInput, PaginationResult } from './types';
|
||||
|
||||
// Mutation inputs
|
||||
export interface ProductInfoInput {
|
||||
name: string;
|
||||
artNo: string;
|
||||
path: string;
|
||||
batch: string;
|
||||
copyright: string;
|
||||
ref1: string;
|
||||
ref2: string;
|
||||
ref3: string;
|
||||
designerId: number;
|
||||
browsable: boolean;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
export interface ProductsFilterInput {
|
||||
pagination: PaginationInput;
|
||||
filter?: ProductsFilter;
|
||||
@@ -39,7 +54,7 @@ export enum ProductWallpaperType {
|
||||
|
||||
export enum Orientation {
|
||||
UNKNOWN = 0,
|
||||
PORTRAIT = 1,
|
||||
STANDING = 1,
|
||||
LANDSCAPE = 2,
|
||||
SQUARE = 3,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user