Browse Source

fixed gql products language selection

bach 4 years ago
parent
commit
14169ab24a

+ 2 - 0
web/modules/custom/materio_graphql/src/Plugin/GraphQL/SchemaExtension/MaterioSchemaExtension.php

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

+ 1 - 1
web/themes/custom/materiotheme/assets/dist/main.js

@@ -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()`{
-        products(ids: [${n.products_ids}]) {
+        products(ids: [${n.products_ids}], lang: "${drupalDecoupled.lang_code}") {
           ...ProductsFields
         }
       }

BIN
web/themes/custom/materiotheme/assets/dist/main.js.gz


File diff suppressed because it is too large
+ 1 - 1
web/themes/custom/materiotheme/assets/dist/report.html


+ 1 - 1
web/themes/custom/materiotheme/vuejs/store/modules/pages.js

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

Some files were not shown because too many files changed in this diff