WIP
This commit is contained in:
Generated
+5
-7
@@ -754,13 +754,6 @@
|
||||
"apollo-server-env": "^3.0.0",
|
||||
"apollo-server-errors": "^2.4.2",
|
||||
"http-cache-semantics": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"apollo-server-errors": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/apollo-server-errors/-/apollo-server-errors-2.4.2.tgz",
|
||||
"integrity": "sha512-FeGxW3Batn6sUtX3OVVUm7o56EgjxDlmgpTLNyWcLb0j6P8mw9oLNyAm3B+deHA4KNdNHO5BmHS2g1SJYjqPCQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"apollo-env": {
|
||||
@@ -911,6 +904,11 @@
|
||||
"util.promisify": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"apollo-server-errors": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/apollo-server-errors/-/apollo-server-errors-2.4.2.tgz",
|
||||
"integrity": "sha512-FeGxW3Batn6sUtX3OVVUm7o56EgjxDlmgpTLNyWcLb0j6P8mw9oLNyAm3B+deHA4KNdNHO5BmHS2g1SJYjqPCQ=="
|
||||
},
|
||||
"apollo-server-express": {
|
||||
"version": "2.22.2",
|
||||
"resolved": "https://registry.npmjs.org/apollo-server-express/-/apollo-server-express-2.22.2.tgz",
|
||||
|
||||
@@ -9,6 +9,7 @@ import resolvers from './resolvers';
|
||||
import { OrderAPI } from './datasources/order-api';
|
||||
import { ProductAPI } from './datasources/product-api';
|
||||
import { DesignerAPI } from './datasources/designer-api';
|
||||
import { Api2DataSource } from './datasources/api2-datasource';
|
||||
|
||||
const knexConfig = knexStringcase(dbConfig);
|
||||
|
||||
@@ -20,6 +21,7 @@ const dataSources = () => ({
|
||||
orderApi: new OrderAPI(knexConfig),
|
||||
productApi: new ProductAPI(knexConfig),
|
||||
designerApi: new DesignerAPI(knexConfig),
|
||||
api2: new Api2DataSource(),
|
||||
});
|
||||
|
||||
const context = async ({ req }) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { orderQueryTypeDefs, orderTypeDefs } from './orders-resolver';
|
||||
import { productQueryTypeDefs, productTypeDefs } from './products-resolver';
|
||||
import { designerQueryTypeDefs, designerTypeDefs } from './designers-resolver';
|
||||
import { DateTimeResolver, DateResolver } from 'graphql-scalars';
|
||||
import { DateTimeResolver, DateResolver, JSONResolver } from 'graphql-scalars';
|
||||
const resolvers = {
|
||||
Query: {
|
||||
...orderQueryTypeDefs,
|
||||
@@ -13,6 +13,7 @@ const resolvers = {
|
||||
...designerTypeDefs,
|
||||
DateTime: DateTimeResolver,
|
||||
Date: DateResolver,
|
||||
JSON: JSONResolver,
|
||||
};
|
||||
|
||||
export default resolvers;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// (parent, args, ctx, info)
|
||||
import { IResolverObject } from 'graphql-tools';
|
||||
import { Api2DataSource } from '../datasources/api2-datasource';
|
||||
import { OrderAPI } from '../datasources/order-api';
|
||||
import { ProductAPI } from '../datasources/product-api';
|
||||
|
||||
@@ -18,6 +19,17 @@ const Product: IResolverObject = {
|
||||
},
|
||||
};
|
||||
|
||||
const PrintProduct: IResolverObject = {
|
||||
async price({ id }, { market, width, height, sku }, { dataSources }) {
|
||||
return (<Api2DataSource>dataSources.api2).getPrice(
|
||||
market,
|
||||
width,
|
||||
height,
|
||||
sku,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
async function getProducts(_, { limit, visible, browsable }, { dataSources }) {
|
||||
return (<ProductAPI>dataSources.productApi).getProducts(
|
||||
limit,
|
||||
@@ -33,6 +45,7 @@ async function getProduct(_, { id }, { dataSources }) {
|
||||
export const productTypeDefs = {
|
||||
ProductBlacklist,
|
||||
Product,
|
||||
PrintProduct,
|
||||
};
|
||||
|
||||
export const productQueryTypeDefs = {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { gql } from 'apollo-server';
|
||||
const typeDefs = gql`
|
||||
scalar DateTime
|
||||
scalar Date
|
||||
scalar JSON
|
||||
|
||||
type Query {
|
||||
orders(filter: FilterInput): [Order]
|
||||
@@ -200,6 +201,7 @@ const typeDefs = gql`
|
||||
group: ProductGroup!
|
||||
inserted: DateTime!
|
||||
updated: DateTime
|
||||
price(market: Int, width: Int, height: Int, sku: String): JSON
|
||||
}
|
||||
|
||||
type Designer {
|
||||
|
||||
Reference in New Issue
Block a user