Skip to content

Commit

Permalink
Revert "feat: #1214071 add/update GQL queries getSearchDocumentsQuery…
Browse files Browse the repository at this point in the history
…, getMoreFacetOptionsQuery and getMoreFacetProductOptionsQuery and the related types"

This reverts commit 811de73.
  • Loading branch information
botisSmile committed Nov 9, 2023
1 parent 811de73 commit 006a67e
Show file tree
Hide file tree
Showing 22 changed files with 152 additions and 230 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { api } from '@elastic-suite/gally-admin-shared/src/mocks'

import catalog from '@elastic-suite/gally-admin-shared/src/mocks/static/catalog.json'
import productSortingOptions from '@elastic-suite/gally-admin-shared/src/mocks/static/product_sorting_options.json'
import categorySortingOptions from '@elastic-suite/gally-admin-shared/src/mocks/static/category_sorting_options.json'
import docs from '@elastic-suite/gally-admin-shared/src/mocks/static/docs.json'
import entrypoint from '@elastic-suite/gally-admin-shared/src/mocks/static/index.json'
import graphql from '@elastic-suite/gally-admin-shared/src/mocks/static/graphql.json'
Expand Down Expand Up @@ -46,9 +46,9 @@ fetchApi.mockImplementation((_, resource) => {
data = { ...metadata }
} else if (
typeof resource === 'string' &&
resource.endsWith('product_sorting_options')
resource.endsWith('category_sorting_options')
) {
data = { ...productSortingOptions }
data = { ...categorySortingOptions }
} else if (
(typeof resource !== 'string' &&
resource.title.toLowerCase() === 'source_field_option_label') ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { useTranslation } from 'next-i18next'

import {
ICategory,
ICategorySortingOption,
IGraphqlProductPosition,
IParsedCategoryConfiguration,
IProductFieldFilterInput,
IProductPositions,
ISortingOption,
LoadStatus,
getProductPosition,
} from '@elastic-suite/gally-admin-shared'
Expand Down Expand Up @@ -110,12 +110,12 @@ function ProductsContainer(props: IProps): JSX.Element {
setBottomSelectedRows([])
}

const resourceName = 'ProductSortingOption'
const resourceName = 'CategorySortingOption'
const resourceSortingOption = useResource(resourceName)
const [{ data }] = useApiList<ISortingOption>(resourceSortingOption)
const [{ data }] = useApiList<ICategorySortingOption>(resourceSortingOption)

const sortOption = data
? data[`hydra:member`].map((obj: ISortingOption) => ({
? data[`hydra:member`].map((obj: ICategorySortingOption) => ({
value: obj.code,
...obj,
}))
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/constants/category.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/shared/src/constants/cmsPage.ts

This file was deleted.

68 changes: 4 additions & 64 deletions packages/shared/src/constants/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { VariableType, jsonToGraphQLQuery } from 'json-to-graphql-query'

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

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

export function getSearchDocumentsQuery(
entityType: string,
filter: IDocumentFieldFilterInput | IDocumentFieldFilterInput[] = null,
withAggregations = false
): string {
const documentQueryContent = getSearchDocumentQueryContent(
filter,
withAggregations,
entityType
)
return jsonToGraphQLQuery({
query: {
__name: 'getDocuments',
__variables: { ...documentQueryContent.variables },
documents: {
__aliasFor: 'documents',
__args: { ...documentQueryContent.args },
...documentQueryContent.fields,
},
},
})
return getSearchDocumentQueryContent(filter, withAggregations, 'category')
}

export function getSearchDocumentQueryContent(
Expand Down Expand Up @@ -190,18 +162,15 @@ export function getSearchDocumentQueryContent(
}

export function getAutoCompleteSearchQuery(
productFilter: IProductFieldFilterInput | IProductFieldFilterInput[] = null,
categoryFilter:
| IDocumentFieldFilterInput
| IDocumentFieldFilterInput[] = null,
filter: IProductFieldFilterInput | IProductFieldFilterInput[] = null,
withAggregations = false
): string {
const productQueryContent = getSearchProductsQueryContent(
productFilter,
filter,
withAggregations
)
const categoryQueryContent = getSearchCategoryQueryContent(
categoryFilter,
filter,
withAggregations
)
return jsonToGraphQLQuery({
Expand All @@ -226,35 +195,6 @@ export function getAutoCompleteSearchQuery(
}

export function getMoreFacetOptionsQuery(
filter: IDocumentFieldFilterInput | IDocumentFieldFilterInput[] = null
): string {
return jsonToGraphQLQuery({
query: {
__name: 'viewMoreFacetOptions',
__variables: {
entityType: 'String!',
localizedCatalog: 'String!',
aggregation: 'String!',
search: 'String',
},
viewMoreFacetOptions: {
__args: {
entityType: new VariableType('entityType'),
localizedCatalog: new VariableType('localizedCatalog'),
aggregation: new VariableType('aggregation'),
search: new VariableType('search'),
filter,
},
id: true,
value: true,
label: true,
count: true,
},
},
})
}

export function getMoreFacetProductOptionsQuery(
filter: IProductFieldFilterInput | IProductFieldFilterInput[] = null
): string {
return jsonToGraphQLQuery({
Expand Down
3 changes: 0 additions & 3 deletions packages/shared/src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
export * from './api'
export * from './category'
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: 0 additions & 1 deletion packages/shared/src/constants/product.ts

This file was deleted.

22 changes: 11 additions & 11 deletions packages/shared/src/mocks/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const fieldDropdownWithApiOptions = {
gally: {
input: 'select',
options: {
api_rest: '/product_sorting_options',
api_rest: '/category_sorting_options',
},
editable: false,
position: 10,
Expand Down Expand Up @@ -1806,26 +1806,26 @@ export const resources = [
url: 'https://localhost/categories',
},
{
'@id': 'https://localhost/docs.jsonld#ProductSortingOption',
'@id': 'https://localhost/docs.jsonld#CategorySortingOption',
'@type': 'http://www.w3.org/ns/hydra/core#Class',
supportedOperation: {
'@type': [
'http://www.w3.org/ns/hydra/core#Operation',
'http://schema.org/FindAction',
],
method: 'GET',
title: 'Retrieves the collection of ProductSortingOption resources.',
label: 'Retrieves the collection of ProductSortingOption resources.',
title: 'Retrieves the collection of CategorySortingOption resources.',
label: 'Retrieves the collection of CategorySortingOption resources.',
returns: { '@id': 'http://www.w3.org/ns/hydra/core#Collection' },
},
supportedProperty: [
{
'@type': 'http://www.w3.org/ns/hydra/core#SupportedProperty',
property: {
'@id': 'https://localhost/docs.jsonld#ProductSortingOption/label',
'@id': 'https://localhost/docs.jsonld#CategorySortingOption/label',
'@type': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property',
domain: {
'@id': 'https://localhost/docs.jsonld#ProductSortingOption',
'@id': 'https://localhost/docs.jsonld#CategorySortingOption',
},
range: { '@id': 'http://www.w3.org/2001/XMLSchema#string' },
label: 'label',
Expand All @@ -1838,10 +1838,10 @@ export const resources = [
{
'@type': 'http://www.w3.org/ns/hydra/core#SupportedProperty',
property: {
'@id': 'https://localhost/docs.jsonld#ProductSortingOption/code',
'@id': 'https://localhost/docs.jsonld#CategorySortingOption/code',
'@type': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property',
domain: {
'@id': 'https://localhost/docs.jsonld#ProductSortingOption',
'@id': 'https://localhost/docs.jsonld#CategorySortingOption',
},
range: { '@id': 'http://www.w3.org/2001/XMLSchema#string' },
label: 'code',
Expand All @@ -1852,9 +1852,9 @@ export const resources = [
writeable: true,
},
],
title: 'ProductSortingOption',
label: 'ProductSortingOption',
url: 'https://localhost/product_sorting_options',
title: 'CategorySortingOption',
label: 'CategorySortingOption',
url: 'https://localhost/category_sorting_options',
},
{
'@id': 'https://localhost/docs.jsonld#CategoryConfiguration',
Expand Down
27 changes: 14 additions & 13 deletions packages/shared/src/mocks/expandedDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2545,19 +2545,20 @@ export const expandedDocs = {
'http://www.w3.org/2000/01/rdf-schema#label': [{ '@value': 'Category' }],
},
{
'@id': 'https://localhost/docs.jsonld#ProductSortingOption',
'@id': 'https://localhost/docs.jsonld#CategorySortingOption',
'@type': ['http://www.w3.org/ns/hydra/core#Class'],
'http://www.w3.org/ns/hydra/core#supportedOperation': [],
'http://www.w3.org/ns/hydra/core#supportedProperty': [
{
'@type': ['http://www.w3.org/ns/hydra/core#SupportedProperty'],
'http://www.w3.org/ns/hydra/core#property': [
{
'@id': 'https://localhost/docs.jsonld#ProductSortingOption/label',
'@id':
'https://localhost/docs.jsonld#CategorySortingOption/label',
'@type': ['http://www.w3.org/1999/02/22-rdf-syntax-ns#Property'],
'http://www.w3.org/2000/01/rdf-schema#domain': [
{
'@id': 'https://localhost/docs.jsonld#ProductSortingOption',
'@id': 'https://localhost/docs.jsonld#CategorySortingOption',
},
],
'http://www.w3.org/2000/01/rdf-schema#range': [
Expand All @@ -2577,11 +2578,11 @@ export const expandedDocs = {
'@type': ['http://www.w3.org/ns/hydra/core#SupportedProperty'],
'http://www.w3.org/ns/hydra/core#property': [
{
'@id': 'https://localhost/docs.jsonld#ProductSortingOption/code',
'@id': 'https://localhost/docs.jsonld#CategorySortingOption/code',
'@type': ['http://www.w3.org/1999/02/22-rdf-syntax-ns#Property'],
'http://www.w3.org/2000/01/rdf-schema#domain': [
{
'@id': 'https://localhost/docs.jsonld#ProductSortingOption',
'@id': 'https://localhost/docs.jsonld#CategorySortingOption',
},
],
'http://www.w3.org/2000/01/rdf-schema#range': [
Expand All @@ -2599,10 +2600,10 @@ export const expandedDocs = {
},
],
'http://www.w3.org/ns/hydra/core#title': [
{ '@value': 'ProductSortingOption' },
{ '@value': 'CategorySortingOption' },
],
'http://www.w3.org/2000/01/rdf-schema#label': [
{ '@value': 'ProductSortingOption' },
{ '@value': 'CategorySortingOption' },
],
},
{
Expand Down Expand Up @@ -4469,7 +4470,7 @@ export const expandedDocs = {
'http://www.w3.org/ns/hydra/core#property': [
{
'@id':
'https://localhost/docs.jsonld#Entrypoint/productSortingOption',
'https://localhost/docs.jsonld#Entrypoint/categorySortingOption',
'@type': ['http://www.w3.org/ns/hydra/core#Link'],
'http://www.w3.org/2000/01/rdf-schema#domain': [
{ '@id': 'https://localhost/docs.jsonld#Entrypoint' },
Expand All @@ -4486,13 +4487,13 @@ export const expandedDocs = {
'http://www.w3.org/ns/hydra/core#title': [
{
'@value':
'Retrieves the collection of ProductSortingOption resources.',
'Retrieves the collection of CategorySortingOption resources.',
},
],
'http://www.w3.org/2000/01/rdf-schema#label': [
{
'@value':
'Retrieves the collection of ProductSortingOption resources.',
'Retrieves the collection of CategorySortingOption resources.',
},
],
'http://www.w3.org/ns/hydra/core#returns': [
Expand All @@ -4502,7 +4503,7 @@ export const expandedDocs = {
],
'http://www.w3.org/2000/01/rdf-schema#label': [
{
'@value': 'The collection of ProductSortingOption resources',
'@value': 'The collection of CategorySortingOption resources',
},
],
'http://www.w3.org/2000/01/rdf-schema#range': [
Expand All @@ -4513,7 +4514,7 @@ export const expandedDocs = {
'http://www.w3.org/2002/07/owl#allValuesFrom': [
{
'@id':
'https://localhost/docs.jsonld#ProductSortingOption',
'https://localhost/docs.jsonld#CategorySortingOption',
},
],
'http://www.w3.org/2002/07/owl#onProperty': [
Expand All @@ -4527,7 +4528,7 @@ export const expandedDocs = {
],
'http://www.w3.org/ns/hydra/core#readable': [{ '@value': true }],
'http://www.w3.org/ns/hydra/core#title': [
{ '@value': 'The collection of ProductSortingOption resources' },
{ '@value': 'The collection of CategorySortingOption resources' },
],
'http://www.w3.org/ns/hydra/core#writeable': [{ '@value': false }],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"@context": "/contexts/ProductSortingOption",
"@id": "/product_sorting_options",
"@context": "/contexts/CategorySortingOption",
"@id": "/category_sorting_options",
"@type": "hydra:Collection",
"hydra:member": [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/mocks/static/contexts/Entrypoint.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
"@type": "@id"
},
"categoryTree": { "@id": "Entrypoint/categoryTree", "@type": "@id" },
"productSortingOption": {
"@id": "Entrypoint/productSortingOption",
"categorySortingOption": {
"@id": "Entrypoint/categorySortingOption",
"@type": "@id"
},
"configuration": { "@id": "Entrypoint/configuration", "@type": "@id" },
Expand Down
Loading

0 comments on commit 006a67e

Please sign in to comment.