This repository has been archived by the owner on Jul 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to ensure added schema types have typeName prefix
- Loading branch information
1 parent
d11483e
commit 145f06b
Showing
2 changed files
with
64 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,125 @@ | ||
// 'Custom' defined schemas, to make sure fields are always available in the Gridsome Schema, and to remove any admin-specific fields | ||
|
||
const ProductSchema = `type Product implements Node { | ||
const ProductSchema = typeName => `type ${typeName}Product implements Node { | ||
id: ID | ||
productChannel: String | ||
archived: Boolean | ||
createdOn: Date | ||
modifiedOn: Date | ||
stripeId: String | ||
name: String | ||
description: String | ||
shortDescription: String | ||
downloadUrl: String | ||
gender: Int | ||
unitOfWeight: Int | ||
weight: Float | ||
isTaxable: Boolean | ||
htsCode: String | ||
unitOfDimensions: Int | ||
height: Float | ||
width: Float | ||
htsCode: String | ||
isTaxable: Boolean | ||
isVendor: Boolean | ||
length: Float | ||
modifiedOn: Date | ||
name: String | ||
productChannel: String | ||
quantity: Int | ||
shortDescription: String | ||
slug: String | ||
stripeId: String | ||
type: Int | ||
downloadUrl: String | ||
archived: Boolean | ||
skus: [Sku] | ||
images: [Images] | ||
seo: Seo | ||
customMetadata: [CustomProductMetadata] | ||
metadata: [ProductMetadata] | ||
collections: [Collection] | ||
isVendor: Boolean | ||
attributes: [ProductAttribute] | ||
quantity: Int | ||
unitOfDimensions: Int | ||
unitOfWeight: Int | ||
variantCount: Int | ||
related: [Product] | ||
weight: Float | ||
width: Float | ||
seo: ${typeName}Seo | ||
skus: [${typeName}Sku] | ||
images: [${typeName}Images] | ||
customMetadata: [${typeName}CustomProductMetadata] | ||
metadata: [${typeName}ProductMetadata] | ||
collections: [${typeName}Collection] | ||
attributes: [${typeName}ProductAttribute] | ||
related: [${typeName}Product] | ||
}` | ||
|
||
const SKUSchema = `type Sku implements Node { | ||
const SKUSchema = typeName => `type ${typeName}Sku implements Node { | ||
basePrice: Int | ||
height: Float | ||
id: ID | ||
sku: String | ||
length: Float | ||
purchaseLimit: Int | ||
basePrice: Int | ||
salePrice: Int | ||
sku: String | ||
unitOfDimensions: Int | ||
unitOfWeight: Int | ||
url: String | ||
weight: Float | ||
unitOfDimensions: Int | ||
height: Float | ||
width: Float | ||
length: Float | ||
product: Product | ||
url: String | ||
image: Image | ||
attributes: [SkuAttribute] | ||
product: ${typeName}Product | ||
attributes: [${typeName}SkuAttribute] | ||
}` | ||
|
||
const ImageSchema = `type Images { | ||
const ImageSchema = typeName => `type ${typeName}Images { | ||
image: Image | ||
}` | ||
|
||
const SEOSchema = `type Seo { | ||
const SEOSchema = typeName => `type ${typeName}Seo { | ||
title: String | ||
description: String | ||
}` | ||
|
||
const ProductMetadata = ` | ||
type ProductMetadata { | ||
const ProductMetadata = typeName => ` | ||
type ${typeName}ProductMetadata { | ||
id: ID! | ||
createdOn: Date! | ||
modifiedOn: Date! | ||
productCategoryTag1: String | ||
productCategoryTag2: String | ||
productCategoryTag3: String | ||
productDominantColor1: String | ||
productDominantColor2: String | ||
productDominantColor3: String | ||
productDominantColor4: String | ||
productDominantColor5: String | ||
productCategoryTag1: String | ||
productCategoryTag2: String | ||
productCategoryTag3: String | ||
productHtsCode: String | ||
} | ||
type CustomProductMetadata { | ||
type ${typeName}CustomProductMetadata { | ||
name: String | ||
value: String | ||
type: CustomProductMetadataType | ||
type: ${typeName}CustomProductMetadataType | ||
} | ||
enum CustomProductMetadataType { | ||
TEXT_INPUT | ||
TEXT_EDITOR | ||
enum ${typeName}CustomProductMetadataType { | ||
DATE_TIME | ||
MEDIA | ||
TEXT_EDITOR | ||
TEXT_INPUT | ||
}` | ||
|
||
const CollectionSchema = `type Collection implements Node { | ||
const CollectionSchema = typeName => `type ${typeName}Collection implements Node { | ||
id: ID! | ||
archived: Boolean! | ||
createdOn: Date! | ||
isAutogenerated: Boolean! | ||
modifiedOn: Date! | ||
name: String! | ||
isAutogenerated: Boolean! | ||
slug: String | ||
products: [Product] | ||
archived: Boolean! | ||
tags: [String] | ||
products: [${typeName}Product] | ||
}` | ||
|
||
const AttributeSchema = ` | ||
type ProductAttribute { | ||
const AttributeSchema = typeName => ` | ||
type ${typeName}ProductAttribute { | ||
key: String | ||
name: String | ||
values: [String] | ||
} | ||
type SkuAttribute { | ||
type ${typeName}SkuAttribute { | ||
key: String | ||
name: String | ||
value: String | ||
} | ||
` | ||
|
||
module.exports = { | ||
ProductSchema, | ||
SKUSchema, | ||
ImageSchema, | ||
SEOSchema, | ||
ProductMetadata, | ||
CollectionSchema, | ||
AttributeSchema | ||
} | ||
module.exports = typeName => [ | ||
ProductSchema(typeName), | ||
SKUSchema(typeName), | ||
ImageSchema(typeName), | ||
SEOSchema(typeName), | ||
ProductMetadata(typeName), | ||
CollectionSchema(typeName), | ||
AttributeSchema(typeName) | ||
] |