fixed gql products language selection

This commit is contained in:
Bachir Soussi Chiadmi 2021-06-02 12:40:46 +02:00
parent 11d781c646
commit 14169ab24a
5 changed files with 6 additions and 4 deletions

View File

@ -1298,6 +1298,7 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('type', $builder->fromValue('commerce_product')) ->map('type', $builder->fromValue('commerce_product'))
// ->map('bundles', $builder->fromValue(['materiau'])) // ->map('bundles', $builder->fromValue(['materiau']))
->map('id', $builder->fromArgument('id')) ->map('id', $builder->fromArgument('id'))
->map('language', $builder->fromArgument('lang'))
); );
$registry->addFieldResolver('Query', 'products', $registry->addFieldResolver('Query', 'products',
@ -1305,6 +1306,7 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('type', $builder->fromValue('commerce_product')) ->map('type', $builder->fromValue('commerce_product'))
// ->map('bundles', $builder->fromValue(['materiau'])) // ->map('bundles', $builder->fromValue(['materiau']))
->map('ids', $builder->fromArgument('ids')) ->map('ids', $builder->fromArgument('ids'))
->map('language', $builder->fromArgument('lang'))
); );
$registry->addFieldResolver('Product', 'id', $registry->addFieldResolver('Product', 'id',

View File

@ -18,7 +18,7 @@
} }
${_()} ${_()}
`;s.E.post("",{query:(0,c.S)(i)}).then((t=>{e("updateItem",t.data.data.searchresult)})).catch((e=>{console.warn("Issue with refreshItem",e),Promise.reject(e)}))}}},k={namespaced:!0,state:{contenttype:null,items:[],page:0,infiniteLoadingState:null},getters:{},mutations:{setItems(e,t){e.items=e.items.concat(t)},incrementPage(e){e.page+=1},setInfiniteState(e,t){e.infiniteLoadingState=t}},actions:{getItems:({dispatch:e,commit:t,state:n})=>f.Z.get(`/blabla_rest?_format=json&page=${n.page}`,{}).then((({data:e})=>{e.length?(t("setItems",e),n.infiniteLoadingState&&n.infiniteLoadingState.loaded()):n.infiniteLoadingState&&n.infiniteLoadingState.complete()})).catch((e=>{console.warn("Issue with blabla getitems",e),Promise.reject(e)})),nextPage({dispatch:e,commit:t,state:n},i){t("incrementPage"),t("setInfiniteState",i),e("getItems")},getItemIndex:({dispatch:e,commit:t,state:n},i)=>n.items.findIndex((e=>e.nid===i)),getPrevNextItems:({dispatch:e,commit:t,state:n},i)=>({prev:n.items[i-1],next:n.items[i+1]})}},S={namespaced:!0,state:{items:[],showrooms_by_tid:{}},getters:{},mutations:{setItems(e,t){e.items=e.items.concat(t),t.forEach(((t,n)=>{e.showrooms_by_tid[t.tid]=t}))}},actions:{getItems({dispatch:e,commit:t,state:n}){f.Z.get("/showrooms_rest?_format=json",{}).then((({data:e})=>{t("setItems",e)})).catch((e=>{console.warn("Issue with showrooms",e),Promise.reject(e)}))}}};var x=n(5277),T=n.n(x);const O={namespaced:!0,state:{products_ids:[],products:[]},getters:{},mutations:{setProductsIds(e,t){e.products_ids=t},setProducts(e,t){e.products=t}},actions:{getProducts({dispatch:e,commit:t,state:n}){e("loadProductsIds")},loadProductsIds({dispatch:e,commit:t,state:n}){f.Z.get("/pricing_rest?_format=json",{}).then((({data:n})=>{const i=[];for(let e=0;e<n.length;e++)i.push(n[e].product_id);t("setProductsIds",i),e("loadProducts")})).catch((e=>{console.warn("Issue with pricing",e),Promise.reject(e)}))},loadProducts({dispatch:e,commit:t,state:n}){const i=u()`{ `;s.E.post("",{query:(0,c.S)(i)}).then((t=>{e("updateItem",t.data.data.searchresult)})).catch((e=>{console.warn("Issue with refreshItem",e),Promise.reject(e)}))}}},k={namespaced:!0,state:{contenttype:null,items:[],page:0,infiniteLoadingState:null},getters:{},mutations:{setItems(e,t){e.items=e.items.concat(t)},incrementPage(e){e.page+=1},setInfiniteState(e,t){e.infiniteLoadingState=t}},actions:{getItems:({dispatch:e,commit:t,state:n})=>f.Z.get(`/blabla_rest?_format=json&page=${n.page}`,{}).then((({data:e})=>{e.length?(t("setItems",e),n.infiniteLoadingState&&n.infiniteLoadingState.loaded()):n.infiniteLoadingState&&n.infiniteLoadingState.complete()})).catch((e=>{console.warn("Issue with blabla getitems",e),Promise.reject(e)})),nextPage({dispatch:e,commit:t,state:n},i){t("incrementPage"),t("setInfiniteState",i),e("getItems")},getItemIndex:({dispatch:e,commit:t,state:n},i)=>n.items.findIndex((e=>e.nid===i)),getPrevNextItems:({dispatch:e,commit:t,state:n},i)=>({prev:n.items[i-1],next:n.items[i+1]})}},S={namespaced:!0,state:{items:[],showrooms_by_tid:{}},getters:{},mutations:{setItems(e,t){e.items=e.items.concat(t),t.forEach(((t,n)=>{e.showrooms_by_tid[t.tid]=t}))}},actions:{getItems({dispatch:e,commit:t,state:n}){f.Z.get("/showrooms_rest?_format=json",{}).then((({data:e})=>{t("setItems",e)})).catch((e=>{console.warn("Issue with showrooms",e),Promise.reject(e)}))}}};var x=n(5277),T=n.n(x);const O={namespaced:!0,state:{products_ids:[],products:[]},getters:{},mutations:{setProductsIds(e,t){e.products_ids=t},setProducts(e,t){e.products=t}},actions:{getProducts({dispatch:e,commit:t,state:n}){e("loadProductsIds")},loadProductsIds({dispatch:e,commit:t,state:n}){f.Z.get("/pricing_rest?_format=json",{}).then((({data:n})=>{const i=[];for(let e=0;e<n.length;e++)i.push(n[e].product_id);t("setProductsIds",i),e("loadProducts")})).catch((e=>{console.warn("Issue with pricing",e),Promise.reject(e)}))},loadProducts({dispatch:e,commit:t,state:n}){const i=u()`{
products(ids: [${n.products_ids}]) { products(ids: [${n.products_ids}], lang: "${drupalDecoupled.lang_code}") {
...ProductsFields ...ProductsFields
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -50,7 +50,7 @@ export default {
}, },
loadProducts ({ dispatch, commit, state }) { loadProducts ({ dispatch, commit, state }) {
const ast = gql`{ const ast = gql`{
products(ids: [${state.products_ids}]) { products(ids: [${state.products_ids}], lang: "${drupalDecoupled.lang_code}") {
...ProductsFields ...ProductsFields
} }
} }