fixed the search results translation with graphql loading

This commit is contained in:
Bachir Soussi Chiadmi 2021-01-12 12:17:50 +01:00
parent efd88d298b
commit 0704a85a63
8 changed files with 44 additions and 19 deletions

View File

@ -11,7 +11,7 @@ extend type Query {
} }
extend type Query { extend type Query {
searchresults(ids: [Int]): [SearchResult] searchresults(ids: [Int], lang: String): [SearchResult]
} }
extend type Query { extend type Query {

View File

@ -109,12 +109,20 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
// | |\/| / _` | _/ -_) '_| / _` | || | // | |\/| / _` | _/ -_) '_| / _` | || |
// |_| |_\__,_|\__\___|_| |_\__,_|\_,_| // |_| |_\__,_|\__\___|_| |_\__,_|\_,_|
protected function addMateriau(ResolverRegistryInterface $registry, ResolverBuilder $builder) { protected function addMateriau(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
// $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$registry->addFieldResolver('Query', 'materiau', $registry->addFieldResolver('Query', 'materiau',
$builder->produce('entity_load') // $builder->compose(
->map('type', $builder->fromValue('node')) $builder->produce('entity_load')
->map('bundles', $builder->fromValue(['materiau'])) ->map('type', $builder->fromValue('node'))
->map('id', $builder->fromArgument('id')) ->map('bundles', $builder->fromValue(['materiau']))
); ->map('id', $builder->fromArgument('id'))
// ->map('language', $builder->fromValue('fr')),
// $builder->produce('entity_translation')
// ->map('entity', $builder->fromParent())
// )
);
$registry->addFieldResolver('Query', 'materiaux', $registry->addFieldResolver('Query', 'materiaux',
$builder->produce('entity_load_multiple') $builder->produce('entity_load_multiple')
@ -274,15 +282,16 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
protected function addSearchResult(ResolverRegistryInterface $registry, ResolverBuilder $builder) { protected function addSearchResult(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
$registry->addFieldResolver('Query', 'searchresults', $registry->addFieldResolver('Query', 'searchresults',
$builder->produce('entity_load_multiple') $builder->produce('entity_load_multiple')
->map('type', $builder->fromValue('node')) ->map('type', $builder->fromValue('node'))
->map('ids', $builder->fromArgument('ids')) ->map('ids', $builder->fromArgument('ids'))
->map('language', $builder->fromArgument('lang'))
); );
$registry->addFieldResolver('SearchResult', 'id', $registry->addFieldResolver('SearchResult', 'id',
$builder->produce('entity_id') $builder->produce('entity_id')
->map('entity', $builder->fromParent()) ->map('entity', $builder->fromParent())
); );
$registry->addFieldResolver('SearchResult', 'bundle', $registry->addFieldResolver('SearchResult', 'bundle',
$builder->produce('entity_bundle') $builder->produce('entity_bundle')
@ -314,7 +323,7 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('type', $builder->fromValue('entity:node')) ->map('type', $builder->fromValue('entity:node'))
->map('value', $builder->fromParent()) ->map('value', $builder->fromParent())
->map('path', $builder->fromValue('field_short_description.value')) ->map('path', $builder->fromValue('field_short_description.value'))
); );
$registry->addFieldResolver('SearchResult', 'images', $registry->addFieldResolver('SearchResult', 'images',
$builder->produce('entity_reference') $builder->produce('entity_reference')

View File

@ -138,6 +138,12 @@ input[type="password"] {
border-radius: 5px; border-radius: 5px;
border: 0.5px solid #aaa; border: 0.5px solid #aaa;
padding: 0.3em 0.4em; } padding: 0.3em 0.4em; }
input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus {
outline: none;
box-shadow: 0 0 2px 1px #8bc4ff; }
.col-1, .small-col-1, .med-col-1, .large-col-1, .col-2, .small-col-2, .med-col-2, .large-col-2, .col-3, .small-col-3, .med-col-3, .large-col-3, .col-4, .small-col-4, .med-col-4, .large-col-4, .col-5, .small-col-5, .med-col-5, .large-col-5, .col-6, .small-col-6, .med-col-6, .large-col-6, .col-7, .small-col-7, .med-col-7, .large-col-7, .col-8, .small-col-8, .med-col-8, .large-col-8, .col-9, .small-col-9, .med-col-9, .large-col-9, .col-10, .small-col-10, .med-col-10, .large-col-10, .col-11, .small-col-11, .med-col-11, .large-col-11, .col-12, .small-col-12, .med-col-12, .large-col-12, .col-1-offset-1, .col-1-offset-2, .col-1-offset-3, .col-1-offset-4, .col-1-offset-5, .col-1-offset-6, .col-1-offset-7, .col-1-offset-8, .col-1-offset-9, .col-1-offset-10, .col-1-offset-11, .col-2-offset-1, .col-2-offset-2, .col-2-offset-3, .col-2-offset-4, .col-2-offset-5, .col-2-offset-6, .col-2-offset-7, .col-2-offset-8, .col-2-offset-9, .col-2-offset-10, .col-3-offset-1, .col-3-offset-2, .col-3-offset-3, .col-3-offset-4, .col-3-offset-5, .col-3-offset-6, .col-3-offset-7, .col-3-offset-8, .col-3-offset-9, .col-4-offset-1, .col-4-offset-2, .col-4-offset-3, .col-4-offset-4, .col-4-offset-5, .col-4-offset-6, .col-4-offset-7, .col-4-offset-8, .col-5-offset-1, .col-5-offset-2, .col-5-offset-3, .col-5-offset-4, .col-5-offset-5, .col-5-offset-6, .col-5-offset-7, .col-6-offset-1, .col-6-offset-2, .col-6-offset-3, .col-6-offset-4, .col-6-offset-5, .col-6-offset-6, .col-7-offset-1, .col-7-offset-2, .col-7-offset-3, .col-7-offset-4, .col-7-offset-5, .col-8-offset-1, .col-8-offset-2, .col-8-offset-3, .col-8-offset-4, .col-9-offset-1, .col-9-offset-2, .col-9-offset-3, .col-10-offset-1, .col-10-offset-2, .col-11-offset-1 { .col-1, .small-col-1, .med-col-1, .large-col-1, .col-2, .small-col-2, .med-col-2, .large-col-2, .col-3, .small-col-3, .med-col-3, .large-col-3, .col-4, .small-col-4, .med-col-4, .large-col-4, .col-5, .small-col-5, .med-col-5, .large-col-5, .col-6, .small-col-6, .med-col-6, .large-col-6, .col-7, .small-col-7, .med-col-7, .large-col-7, .col-8, .small-col-8, .med-col-8, .large-col-8, .col-9, .small-col-9, .med-col-9, .large-col-9, .col-10, .small-col-10, .med-col-10, .large-col-10, .col-11, .small-col-11, .med-col-11, .large-col-11, .col-12, .small-col-12, .med-col-12, .large-col-12, .col-1-offset-1, .col-1-offset-2, .col-1-offset-3, .col-1-offset-4, .col-1-offset-5, .col-1-offset-6, .col-1-offset-7, .col-1-offset-8, .col-1-offset-9, .col-1-offset-10, .col-1-offset-11, .col-2-offset-1, .col-2-offset-2, .col-2-offset-3, .col-2-offset-4, .col-2-offset-5, .col-2-offset-6, .col-2-offset-7, .col-2-offset-8, .col-2-offset-9, .col-2-offset-10, .col-3-offset-1, .col-3-offset-2, .col-3-offset-3, .col-3-offset-4, .col-3-offset-5, .col-3-offset-6, .col-3-offset-7, .col-3-offset-8, .col-3-offset-9, .col-4-offset-1, .col-4-offset-2, .col-4-offset-3, .col-4-offset-4, .col-4-offset-5, .col-4-offset-6, .col-4-offset-7, .col-4-offset-8, .col-5-offset-1, .col-5-offset-2, .col-5-offset-3, .col-5-offset-4, .col-5-offset-5, .col-5-offset-6, .col-5-offset-7, .col-6-offset-1, .col-6-offset-2, .col-6-offset-3, .col-6-offset-4, .col-6-offset-5, .col-6-offset-6, .col-7-offset-1, .col-7-offset-2, .col-7-offset-3, .col-7-offset-4, .col-7-offset-5, .col-8-offset-1, .col-8-offset-2, .col-8-offset-3, .col-8-offset-4, .col-9-offset-1, .col-9-offset-2, .col-9-offset-3, .col-10-offset-1, .col-10-offset-2, .col-11-offset-1 {
width: 100%; width: 100%;

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,7 @@ $color-base:#69cdcf;
$color-showrooms:#50aa3c; $color-showrooms:#50aa3c;
$color-blabla:#9458aa; $color-blabla:#9458aa;
$color-webshowroom:rgb(255, 159, 80); $color-webshowroom:rgb(255, 159, 80);
$color-focus:#8bc4ff;
$alpha: 0.90; $alpha: 0.90;
$color-base-transparent: change-color($color-base, $alpha: $alpha); $color-base-transparent: change-color($color-base, $alpha: $alpha);
$color-showrooms-transparent: change-color($color-showrooms, $alpha: $alpha); $color-showrooms-transparent: change-color($color-showrooms, $alpha: $alpha);

View File

@ -41,10 +41,11 @@ input[type="password"]{
border-radius: 5px; border-radius: 5px;
border : 0.5px solid #aaa; border : 0.5px solid #aaa;
padding: 0.3em 0.4em; padding: 0.3em 0.4em;
// &:focus{ &:focus{
// outline: none; outline: none;
// border-color: blue; // border-color: blue;
// } box-shadow: 0 0 2px 1px $color-focus;
}
// outline-style: solid; // outline-style: solid;
// outline-width: 1px; // outline-width: 1px;
} }

View File

@ -1,6 +1,6 @@
@import './base/reset';
@import './base/variables'; @import './base/variables';
@import './base/colors'; @import './base/colors';
@import './base/reset';
@import './base/grid'; @import './base/grid';
@import './base/layout'; @import './base/layout';
@import './base/animations'; @import './base/animations';

View File

@ -120,7 +120,7 @@ export default {
// callBack: 'loadSearchResultsCallBack' // callBack: 'loadSearchResultsCallBack'
// }) // })
let ast = gql`{ let ast = gql`{
searchresults(ids: [${data.nids}]) { searchresults(ids: [${data.nids}], lang: "${drupalDecoupled.lang_code}") {
...SearchResultFields ...SearchResultFields
} }
} }