added new doleance fields to graphql schema

This commit is contained in:
Bachir Soussi Chiadmi 2023-05-09 11:54:54 +02:00
parent 8ee327f2bf
commit c818cb92c2
2 changed files with 83 additions and 1 deletions

View File

@ -16,6 +16,7 @@ type Concernement implements NodeInterface {
caillou: String
recit: Filefield
entites: [Entiteintegre]
doleances: [Doleance]
}
type Entiteintegre {
@ -50,6 +51,18 @@ type Source {
videos: [VideoLink]
}
type Doleance {
description: String!
etapes: [Etape]
}
type Etape {
date: Date
description: String
documents: [Filefield]
type: Int
}
type Static implements NodeInterface {
id: Int!
uuid: String!

View File

@ -38,6 +38,10 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
//
$this->addSource($registry, $builder);
//
$this->addDoleance($registry, $builder);
//
$this->addEtape($registry, $builder);
//
$this->addStatic($registry, $builder);
//
$this->addGroup($registry, $builder);
@ -212,6 +216,12 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('entity', $builder->fromParent())
->map('field', $builder->fromValue('field_entite'))
);
$registry->addFieldResolver('Concernement', 'doleances',
$builder->produce('entity_reference_revisions')
->map('entity', $builder->fromParent())
->map('field', $builder->fromValue('field_doleancer'))
);
}
// _____ _ _ _ __ ___ _ __ __
@ -428,7 +438,7 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('path', $builder->fromValue('field_liens'))
);
$registry->addFieldResolver('Source', 'date',
$registry->addFieldResolver('Source', 'date',
$builder->produce('property_path')
->map('type', $builder->fromValue('entity:paragraph'))
->map('value', $builder->fromParent())
@ -443,6 +453,65 @@ class OuattSchemaExtension extends SdlSchemaExtensionPluginBase {
);
}
// ____ _
// | _ \ ___ | | ___ __ _ _ __ ___ ___
// | | | |/ _ \| |/ _ \/ _` | '_ \ / __/ _ \
// | |_| | (_) | | __/ (_| | | | | (_| __/
// |____/ \___/|_|\___|\__,_|_| |_|\___\___|
protected function addDoleance(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
$registry->addFieldResolver('Doleance', 'description',
$builder->produce('property_path')
->map('type', $builder->fromValue('entity:paragraph'))
->map('value', $builder->fromParent())
->map('path', $builder->fromValue('field_description.value'))
);
$registry->addFieldResolver('Doleance', 'etapes',
$builder->produce('entity_reference_revisions')
->map('entity', $builder->fromParent())
->map('field', $builder->fromValue('field_etapes'))
);
}
// _____ _
// | ____| |_ __ _ _ __ ___
// | _| | __/ _` | '_ \ / _ \
// | |___| || (_| | |_) | __/
// |_____|\__\__,_| .__/ \___|
// |_|
protected function addEtape(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
$registry->addFieldResolver('Etape', 'description',
$builder->produce('property_path')
->map('type', $builder->fromValue('entity:paragraph'))
->map('value', $builder->fromParent())
->map('path', $builder->fromValue('field_description.value'))
);
$registry->addFieldResolver('Etape', 'date',
$builder->produce('property_path')
->map('type', $builder->fromValue('entity:paragraph'))
->map('value', $builder->fromParent())
->map('path', $builder->fromValue('field_date'))
);
$registry->addFieldResolver('Etape', 'documents',
$builder->produce('property_path')
->map('type', $builder->fromValue('entity:paragraph'))
->map('value', $builder->fromParent())
->map('path', $builder->fromValue('field_documents'))
);
$registry->addFieldResolver('Etape', 'type',
$builder->produce('property_path')
->map('type', $builder->fromValue('entity:paragraph'))
->map('value', $builder->fromParent())
->map('path', $builder->fromValue('field_type.value'))
);
}
// ___ _ _ _
// / __| |_ __ _| |_(_)__ ___
// \__ \ _/ _` | _| / _(_-<