Skip to content

Commit

Permalink
Merge pull request #5 from vtex-apps/feature/translatableV2
Browse files Browse the repository at this point in the history
Use translatable2 directive
  • Loading branch information
tlgimenes authored Sep 24, 2019
2 parents 7d29f6d + 5ef9e30 commit 247e600
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 296 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Use translatableV2
- Use translateV2 in search term

## [0.3.0] - 2019-09-20
### Added
Expand Down
6 changes: 3 additions & 3 deletions graphql/types/Brand.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ type Brand {
""" Text link"""
slug: String
""" Name of brand """
name: String @translatable
name: String @translatableV2
""" Title used by html tag"""
titleTag: String @translatable
titleTag: String @translatableV2
""" Description used by html tag"""
metaTagDescription: String @translatable
metaTagDescription: String @translatableV2
""" Brand is active """
active: Boolean
}
6 changes: 3 additions & 3 deletions graphql/types/Category.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ type Category {
""" Category ID """
id: Int
""" Category name """
name: String @translatable
name: String @translatableV2
""" Title used by html tag"""
titleTag: String @translatable
titleTag: String @translatableV2
""" Description used by html tag"""
hasChildren: Boolean
""" Has children categories """
metaTagDescription: String @translatable
metaTagDescription: String @translatableV2
""" Categories children """
children: [Category]
}
8 changes: 4 additions & 4 deletions graphql/types/Facets.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Facets {
type DepartmentFacet {
id: ID!
quantity: Int!
name: String @translatable
name: String @translatableV2
link: String!
linkEncoded: String!
map: String
Expand All @@ -31,7 +31,7 @@ type BrandFacet {

type PriceRangesFacet {
quantity: Int!
name: String @translatable
name: String @translatableV2
link: String!
linkEncoded: String!
map: String
Expand All @@ -43,7 +43,7 @@ type PriceRangesFacet {
type CategoriesTreeFacet {
id: ID!
quantity: Int!
name: String @translatable
name: String @translatableV2
link: String!
linkEncoded: String!
"""
Expand All @@ -58,7 +58,7 @@ type CategoriesTreeFacet {

type FilterFacet {
quantity: Int!
name: String @translatable
name: String @translatableV2
link: String!
linkEncoded: String!
map: String
Expand Down
28 changes: 14 additions & 14 deletions graphql/types/Product.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ type Product {
"""
Brand of the product
"""
brand: String @translatable
brand: String @translatableV2
"""
Id of the brand of the product
"""
Expand Down Expand Up @@ -31,7 +31,7 @@ type Product {
"""
Product description
"""
description: String @translatable
description: String @translatableV2
"""
SKU objects of the product
"""
Expand All @@ -51,7 +51,7 @@ type Product {
"""
Product name
"""
productName: String @translatable
productName: String @translatableV2
"""
Array of product properties
"""
Expand All @@ -67,11 +67,11 @@ type Product {
"""
Title used by html tag
"""
titleTag: String @translatable
titleTag: String @translatableV2
"""
Description used by html tag
"""
metaTagDescription: String @translatable
metaTagDescription: String @translatableV2
"""
Related Products
"""
Expand Down Expand Up @@ -135,8 +135,8 @@ type Recommendation {

type SKU {
itemId: ID
name: String @translatable
nameComplete: String @translatable
name: String @translatableV2
nameComplete: String @translatableV2
complementName: String
ean: String
referenceId: [Reference]
Expand All @@ -151,13 +151,13 @@ type SKU {
}

type skuSpecification {
fieldName: String @translatable
fieldValues: [String] @translatable
fieldName: String @translatableV2
fieldValues: [String] @translatableV2
}

type productSpecification {
fieldName: String @translatable
fieldValues: [String] @translatable
fieldName: String @translatableV2
fieldValues: [String] @translatableV2
}

input ProductUniqueIdentifier {
Expand Down Expand Up @@ -273,13 +273,13 @@ type Video {
}

type SpecificationGroup {
name: String @translatable
name: String @translatableV2
specifications: [SpecificationGroupProperty]
}

type SpecificationGroupProperty {
name: String @translatable
values: [String] @translatable
name: String @translatableV2
values: [String] @translatableV2
}

type Property {
Expand Down
2 changes: 1 addition & 1 deletion graphql/types/ProductSearch.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type ProductSearch {
}

type SearchBreadcrumb {
name: String @translatable
name: String @translatableV2
href: String
}

Expand Down
2 changes: 1 addition & 1 deletion graphql/types/Suggestions.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Suggestions {

type Items {
thumb: String
name: String @translatable
name: String @translatableV2
href: String
criteria: String
slug: String
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"vendor": "vtex",
"name": "search-graphql",
"version": "0.3.0",
"version": "0.4.0-beta.1",
"title": "GraphQL API for the VTEX store APIs",
"description": "GraphQL schema and resolvers for the VTEX API for the catalog and orders.",
"credentialType": "absolute",
Expand Down
2 changes: 1 addition & 1 deletion node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@types/node": "10.x",
"@types/qs": "^6.5.1",
"@types/ramda": "^0.26.21",
"@vtex/api": "^3.41.0",
"@vtex/api": "^3.54.1",
"@vtex/test-tools": "^1.2.0",
"@vtex/tsconfig": "^0.2.0",
"eslint": "^5.15.3",
Expand Down
2 changes: 1 addition & 1 deletion node/resolvers/catalog/assemblyOption.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ test('should return a BOOLEAN type', async () => {
expect(thingB.maxLength).toBe(undefined)
expect(thingB.domain).not.toBeDefined()
expect(thingB.defaultValue).toBe(false)
})
})
13 changes: 0 additions & 13 deletions node/resolvers/catalog/autocomplete.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { path, split } from 'ramda'

import { toIOMessage, toProductIOMessage } from '../../utils/ioMessage'

/**
* It will extract the slug from the HREF in the item
* passed as parameter.
Expand All @@ -22,17 +20,6 @@ const extractSlug = (item: CatalogAutocompleteUnit) => {

export const resolvers = {
Items: {
name: (
{ name, items }: CatalogAutocompleteUnit,
_: any,
{ clients: { segment } }: Context
) => {
const id = path<string>([0, 'productId'], items)
return id != null
? toProductIOMessage('name')(segment, name, id)
: toIOMessage(segment, name, name)
},

slug: (root: CatalogAutocompleteUnit) => extractSlug(root),

productId: ({ items }: CatalogAutocompleteUnit) =>
Expand Down
17 changes: 1 addition & 16 deletions node/resolvers/catalog/brand.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
import { prop } from 'ramda'

import { toBrandIOMessage } from './../../utils/ioMessage'
import { catalogSlugify } from '../../utils/slug'

export const resolvers = {
Brand: {
name: ({ name, id }: Brand, _: any, { clients: { segment } }: Context) =>
toBrandIOMessage('name')(segment, name, id),

titleTag: (
{ title, id }: Brand,
_: any,
{ clients: { segment } }: Context
) => title && toBrandIOMessage('titleTag')(segment, title, id),

metaTagDescription: (
{ metaTagDescription, id }: Brand,
_: any,
{ clients: { segment } }: Context
) =>
metaTagDescription &&
toBrandIOMessage('metaTagDescription')(segment, metaTagDescription, id),
titleTag: prop('title'),

active: prop('isActive'),

Expand Down
29 changes: 2 additions & 27 deletions node/resolvers/catalog/category.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { compose, last, prop, split } from 'ramda'

import { toCategoryIOMessage } from '../../utils/ioMessage'
import { getCategoryInfo } from './utils'

const lastSegment = compose<string, string[], string>(
Expand Down Expand Up @@ -35,33 +34,9 @@ export const resolvers = {
return pathToCategoryHref(path)
},

name: async (
{ id, name }: SafeCategory,
_: any,
{ clients: { segment } }: Context
) => {
return toCategoryIOMessage('name')(segment, name, id)
},

metaTagDescription: async (
{ id, MetaTagDescription }: SafeCategory,
_: any,
{ clients: { segment } }: Context
) => {
return toCategoryIOMessage('metaTagDescription')(
segment,
MetaTagDescription,
id
)
},
metaTagDescription: prop('MetaTagDescription'),

titleTag: async (
{ id, Title }: SafeCategory,
_: any,
{ clients: { segment } }: Context
) => {
return toCategoryIOMessage('titleTag')(segment, Title, id)
},
titleTag: prop('Title'),

slug: async ({ url }: SafeCategory, _: any) => {
return url ? lastSegment(url) : null
Expand Down
24 changes: 3 additions & 21 deletions node/resolvers/catalog/facets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { prop, toPairs } from 'ramda'

import { toCategoryIOMessage, toFacetIOMessage } from '../../utils/ioMessage'
import { pathToCategoryHref } from './category'
import { zipQueryAndMap } from './utils'

Expand Down Expand Up @@ -65,27 +64,14 @@ export const resolvers = {
FilterFacet: {
...baseFacetResolvers,

name: async (
{ Map, Name }: CatalogFacet,
_: any,
{ clients: { segment } }: Context
) => {
const [, id] = Map.split('_')
return toFacetIOMessage(segment, Name, id)
},
name: prop('Name'),
},
DepartmentFacet: {
...baseFacetResolvers,

id: prop('Id'),

name: async (
{ Id, Name }: CatalogFacet & { Id?: number },
_: any,
{ clients: { segment } }: Context
) => {
return Id != null ? toCategoryIOMessage('name')(segment, Name, Id) : Name
},
name: prop('Name'),
},
BrandFacet: {
...baseFacetResolvers,
Expand All @@ -109,11 +95,7 @@ export const resolvers = {
return pathToCategoryHref(linkPath)
},

name: (
{ Id, Name }: CatalogFacetCategory,
_: any,
{ clients: { segment } }: Context
) => toCategoryIOMessage('name')(segment, Name, Id),
name: prop('Name'),
},
Facets: {
departments: ({
Expand Down
Loading

0 comments on commit 247e600

Please sign in to comment.