gql missing field_creations on textref #1269

This commit is contained in:
2021-06-30 10:27:41 +02:00
parent a8daf129f7
commit d9b128faba
4 changed files with 59 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"serverSourceRoot":"192.168.0.21"
"port": 9001,
"pathMappings": {
"/var/www/html/d8.materio.com/public_html": "${workspaceFolder}"
},
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9001
}
]
}
@@ -53,6 +53,7 @@ type Textref implements NodeInterface & TextInterface & MapItemInterface{
tags: [Taxoterm]
degres_detrangement: Int
notes: [Noteref]
field_creations: [Creation]
}
type Textprod implements NodeInterface & TextInterface & MapItemInterface {
@@ -69,6 +69,10 @@ extend type Query {
alltags: [Taxoterm]
}
# extend type Query {
# famillytags(famillyid: Int!): [Taxoterm]
# }
extend type Query {
tag(id: Int!): Taxoterm
}
@@ -156,6 +156,7 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase {
);
}
// MapItems
protected function addMapItems(ResolverRegistryInterface $registry, ResolverBuilder $builder){
// Tell GraphQL how to resolve types of a common interface.
$registry->addTypeResolver('MapItemInterface', function ($value) {
@@ -304,6 +305,13 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('field', $builder->fromValue('field_textes_produits'))
));
$registry->addFieldResolver('Textref', 'field_creations',
$builder->compose(
$builder->produce('entity_reference')
->map('entity', $builder->fromParent())
->map('field', $builder->fromValue('field_creations'))
));
$registry->addFieldResolver('Textref', 'images',
$builder->produce('entity_reference')
->map('entity', $builder->fromParent())
@@ -1035,6 +1043,26 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase {
->map('id', $builder->fromArgument('id'))
);
// get all tags for a given familly
// $registry->addFieldResolver('Query', 'famillytags',
// $builder->compose(
// $builder->callback(function($parent, $arg){
// $entity_storage = \Drupal::entityTypeManager()->getStorage('node');
// $query = $entity_storage->getQuery()
// ->condition('type', ['texte', 'texte_prod'], 'IN')
// ->condition('field_famille', $arg->famillyid)
// ->accessCheck(TRUE);
// $results = $query->execute();
// return $results;
// }),
// $builder->produce('entity_load_multiple')
// ->map('type', $builder->fromValue('node'))
// ->map('ids', $builder->fromParent())
// // $builder->produce('entity_load_multiple')
// // ->map('type', $builder->fromValue('taxonomy_term'))
// // ->map('ids', $builder->fromParent())
// )
// );
$registry->addFieldResolver('Taxoterm', 'id',