Skip to content

Commit

Permalink
fix: draft
Browse files Browse the repository at this point in the history
  • Loading branch information
botisSmile committed Oct 31, 2023
1 parent 9d68640 commit cc4e61a
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 29 deletions.
30 changes: 20 additions & 10 deletions packages/shared/src/constants/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { VariableType, jsonToGraphQLQuery } from 'json-to-graphql-query'

import { IGraphqlQueryContent, IProductFieldFilterInput } from '../types'
import { IDocumentFieldFilterInput } from '../types/documents'
import {categoryEntityType} from "./category";
import { categoryEntityType } from './category'

export function getSearchProductsQuery(
filter: IProductFieldFilterInput | IProductFieldFilterInput[] = null,
Expand Down Expand Up @@ -99,18 +99,22 @@ export function getSearchCategoryQueryContent(
filter: IDocumentFieldFilterInput | IDocumentFieldFilterInput[] = null,
withAggregations = false
): IGraphqlQueryContent {
return getSearchDocumentQueryContent(filter, withAggregations, categoryEntityType)
return getSearchDocumentQueryContent(
filter,
withAggregations,
categoryEntityType
)
}

export function getSearchDocumentsQuery(
entityType: string,
filter: IDocumentFieldFilterInput | IDocumentFieldFilterInput[] = null,
withAggregations = false
entityType: string,
filter: IDocumentFieldFilterInput | IDocumentFieldFilterInput[] = null,
withAggregations = false
): string {
const documentQueryContent = getSearchDocumentQueryContent(
filter,
withAggregations,
entityType
filter,
withAggregations,
entityType
)
return jsonToGraphQLQuery({
query: {
Expand Down Expand Up @@ -187,7 +191,9 @@ export function getSearchDocumentQueryContent(

export function getAutoCompleteSearchQuery(
productFilter: IProductFieldFilterInput | IProductFieldFilterInput[] = null,
categoryFilter: IDocumentFieldFilterInput | IDocumentFieldFilterInput[] = null,
categoryFilter:
| IDocumentFieldFilterInput
| IDocumentFieldFilterInput[] = null,
withAggregations = false
): string {
const productQueryContent = getSearchProductsQueryContent(
Expand Down Expand Up @@ -220,7 +226,11 @@ export function getAutoCompleteSearchQuery(
}

export function getMoreFacetOptionsQuery(
filter: IProductFieldFilterInput | IProductFieldFilterInput[] = null
filter:
| IProductFieldFilterInput
| IProductFieldFilterInput[]
| IDocumentFieldFilterInput
| IDocumentFieldFilterInput[] = null
): string {
return jsonToGraphQLQuery({
query: {
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './cmsPage'
export * from './customTable'
export * from './graphql'
export * from './hydra'
export * from './product'
export * from './rules'
export * from './theme'
export * from './url'
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/constants/product.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const productEntityType = 'product'
26 changes: 26 additions & 0 deletions packages/shared/src/types/facet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { IProductFieldFilterInput } from './products'
import { IDocumentFieldFilterInput } from './documents'

export interface IGraphqlViewMoreFacetOption {
id: string
value: string
label: string
count: number
}

export interface IGraphqlViewMoreFacetOptionsVariables {
entityType: string
aggregation: string
localizedCatalog: string
currentCategoryId?: string
filter?:
| IProductFieldFilterInput[]
| IProductFieldFilterInput
| IDocumentFieldFilterInput[]
| IDocumentFieldFilterInput
search?: string
}

export interface IGraphqlViewMoreFacetOptions {
viewMoreProductFacetOptions: IGraphqlViewMoreFacetOption[]
}
1 change: 1 addition & 0 deletions packages/shared/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from './entrypoint'
export * from './expansion'
export * from './extraBundle'
export * from './extraConfiguration'
export * from './facet'
export * from './fetch'
export * from './field'
export * from './form'
Expand Down
19 changes: 0 additions & 19 deletions packages/shared/src/types/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,3 @@ export interface IProductFieldFilterInput {
boolFilter?: IProductBoolFilterInput
[key: string]: ITypeFilterInput
}

export interface IGraphqlViewMoreFacetOption {
id: string
value: string
label: string
count: number
}

export interface IGraphqlViewMoreFacetOptionsVariables {
aggregation: string
localizedCatalog: string
currentCategoryId?: string
filter?: IProductFieldFilterInput[] | IProductFieldFilterInput
search?: string
}

export interface IGraphqlViewMoreFacetOptions {
viewMoreProductFacetOptions: IGraphqlViewMoreFacetOption[]
}

0 comments on commit cc4e61a

Please sign in to comment.