fixed graphql linked_materials entity_reference translation
This commit is contained in:
parent
bc2bd2861c
commit
2cf2f378ce
|
@ -96,6 +96,7 @@ third_party_settings:
|
|||
- field_workflow
|
||||
- field_migration
|
||||
- field_memo
|
||||
- translation
|
||||
parent_name: ''
|
||||
weight: 1
|
||||
format_type: tab
|
||||
|
@ -240,12 +241,13 @@ content:
|
|||
placeholder: ''
|
||||
third_party_settings: { }
|
||||
translation:
|
||||
weight: 3
|
||||
weight: 7
|
||||
region: content
|
||||
settings: { }
|
||||
third_party_settings: { }
|
||||
hidden:
|
||||
created: true
|
||||
flag: true
|
||||
path: true
|
||||
promote: true
|
||||
status: true
|
||||
|
|
|
@ -14,7 +14,7 @@ bundle: article
|
|||
label: Body
|
||||
description: ''
|
||||
required: false
|
||||
translatable: false
|
||||
translatable: true
|
||||
default_value: { }
|
||||
default_value_callback: ''
|
||||
settings:
|
||||
|
|
|
@ -3,8 +3,12 @@ langcode: en
|
|||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- field_permissions
|
||||
- node
|
||||
- text
|
||||
third_party_settings:
|
||||
field_permissions:
|
||||
permission_type: public
|
||||
_core:
|
||||
default_config_hash: EBUo7qOWqaiZaQ_RC9sLY5IoDKphS34v77VIHSACmVY
|
||||
id: node.body
|
||||
|
|
|
@ -8,7 +8,7 @@ dependencies:
|
|||
- content_translation
|
||||
third_party_settings:
|
||||
content_translation:
|
||||
enabled: false
|
||||
enabled: true
|
||||
bundle_settings:
|
||||
untranslatable_fields_hide: '0'
|
||||
id: node.article
|
||||
|
|
|
@ -3,7 +3,7 @@ session:
|
|||
url:
|
||||
source: path_prefix
|
||||
prefixes:
|
||||
en: ''
|
||||
en: en
|
||||
fr: fr
|
||||
domains:
|
||||
en: ''
|
||||
|
|
|
@ -24,16 +24,15 @@ negotiation:
|
|||
language_interface:
|
||||
enabled:
|
||||
language-url: -20
|
||||
language-user: -19
|
||||
language-browser: -18
|
||||
language-selected: -17
|
||||
method_weights:
|
||||
language-graphql-operation: -15
|
||||
language-user-admin: -14
|
||||
language-url: -20
|
||||
language-session: -16
|
||||
language-user: -19
|
||||
language-browser: -18
|
||||
language-selected: -17
|
||||
language-session: -16
|
||||
language-graphql-operation: -15
|
||||
language-user-admin: -14
|
||||
_core:
|
||||
default_config_hash: dqouFqVseNJNvEjsoYKxbinFOITuCxYhi4y2OTNQP_8
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
extend type Query {
|
||||
route(path: String!): NodeInterface
|
||||
route(path: String!, lang: String): NodeInterface
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
materiau(id: Int!): Materiau
|
||||
materiau(id: Int!, lang: String): Materiau
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
materiaux(ids: [Int]): [Materiau]
|
||||
materiaux(ids: [Int], lang: String): [Materiau]
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
|
@ -15,35 +15,35 @@ extend type Query {
|
|||
}
|
||||
|
||||
extend type Query {
|
||||
article(id: Int!): Article
|
||||
article(id: Int!, lang: String): Article
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
thematique(id: Int!): Thematique
|
||||
thematique(id: Int!, lang: String): Thematique
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
showroom(id: Int!): Showroom
|
||||
showroom(id: Int!, lang: String): Showroom
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
tag(id: Int!): Tag
|
||||
tag(id: Int!, lang: String): Tag
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
thesaurus(id: Int!): Thesaurus
|
||||
thesaurus(id: Int!, lang: String): Thesaurus
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
company(id: Int!): Company
|
||||
company(id: Int!, lang: String): Company
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
product(id: Int!): Product
|
||||
product(id: Int!, lang: String): Product
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
products(ids: [Int]): [Product]
|
||||
products(ids: [Int], lang: String): [Product]
|
||||
}
|
||||
|
||||
# extend type Query {
|
||||
|
|
|
@ -101,6 +101,7 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|||
->map('path', $builder->fromArgument('path')),
|
||||
$builder->produce('route_entity')
|
||||
->map('url', $builder->fromParent())
|
||||
->map('language', $builder->fromArgument('lang'))
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -113,15 +114,11 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|||
// $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
|
||||
$registry->addFieldResolver('Query', 'materiau',
|
||||
// $builder->compose(
|
||||
$builder->produce('entity_load')
|
||||
->map('type', $builder->fromValue('node'))
|
||||
->map('bundles', $builder->fromValue(['materiau']))
|
||||
->map('id', $builder->fromArgument('id'))
|
||||
// ->map('language', $builder->fromValue('fr')),
|
||||
// $builder->produce('entity_translation')
|
||||
// ->map('entity', $builder->fromParent())
|
||||
// )
|
||||
->map('language', $builder->fromArgument('lang'))
|
||||
);
|
||||
|
||||
$registry->addFieldResolver('Query', 'materiaux',
|
||||
|
@ -129,6 +126,7 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|||
->map('type', $builder->fromValue('node'))
|
||||
// ->map('bundles', $builder->fromValue(['materiau']))
|
||||
->map('ids', $builder->fromArgument('ids'))
|
||||
->map('language', $builder->fromArgument('lang'))
|
||||
);
|
||||
|
||||
$registry->addFieldResolver('Materiau', 'id',
|
||||
|
@ -374,6 +372,7 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|||
->map('type', $builder->fromValue('node'))
|
||||
->map('bundles', $builder->fromValue(['article']))
|
||||
->map('id', $builder->fromArgument('id'))
|
||||
->map('language', $builder->fromArgument('lang'))
|
||||
);
|
||||
|
||||
$registry->addFieldResolver('Article', 'id',
|
||||
|
@ -425,9 +424,36 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|||
// https://github.com/drupal-graphql/graphql/blob/8.x-4.x/doc/SUMMARY.md
|
||||
// https://blog.chrismitchellonline.com/posts/custom_graphql_data/
|
||||
$registry->addFieldResolver('Article', 'linked_materials',
|
||||
$builder->produce('entity_reference')
|
||||
->map('entity', $builder->fromParent())
|
||||
->map('field', $builder->fromValue('field_linked_materials'))
|
||||
// $builder->produce('entity_reference')
|
||||
// ->map('entity', $builder->fromParent())
|
||||
// ->map('field', $builder->fromValue('field_linked_materials'))
|
||||
// ->map('language', $builder->fromValue('fr')) // this is not working
|
||||
// // ->map('language', $builder->produce('entity_language')
|
||||
// // ->map('entity', $builder->fromParent())) // neither that
|
||||
$builder->compose(
|
||||
$builder->callback(function($parent, $args){
|
||||
$linkedmaterials = $parent->get('field_linked_materials')->getValue();
|
||||
$nids = [];
|
||||
foreach ($linkedmaterials as $key => $value) {
|
||||
$nids[] = $value['target_id'];
|
||||
}
|
||||
$lang = $parent->language()->getId();
|
||||
$test="test";
|
||||
return [
|
||||
"ids" => $nids,
|
||||
"language" => $lang
|
||||
];
|
||||
}),
|
||||
$builder->produce('entity_load_multiple')
|
||||
->map('type', $builder->fromValue('node'))
|
||||
->map('bundles', $builder->fromValue(['materiau']))
|
||||
->map('ids', $builder->callback(function($parent, $args){
|
||||
return $parent['ids'];
|
||||
}))
|
||||
->map('language', $builder->callback(function($parent, $args){
|
||||
return $parent['language'];
|
||||
}))
|
||||
)
|
||||
);
|
||||
|
||||
$registry->addFieldResolver('Article', 'images',
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -29,7 +29,7 @@ export default {
|
|||
props: ['item'],
|
||||
data(){
|
||||
return {
|
||||
alias: this.item.view_node.replace(/^.?\/blabla\//g, '')
|
||||
alias: this.item.view_node.replace(/^.*\/blabla\//g, '')
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
|
|
|
@ -117,7 +117,7 @@ export default {
|
|||
console.log('loadMaterial', this.item.id)
|
||||
this.loading = true
|
||||
let ast = gql`{
|
||||
materiau(id: ${this.item.id}) {
|
||||
materiau(id: ${this.item.id}, lang: "${drupalDecoupled.lang_code}") {
|
||||
...MateriauFields
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ export default {
|
|||
this.loading = true
|
||||
|
||||
let ast = gql`{
|
||||
route(path: "${this.path}") {
|
||||
route(path: "${this.path}", lang: "${drupalDecoupled.lang_code}") {
|
||||
...ArticleFields
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue