add queries mapitems(ids) & allmapitemsof(familyId)
This commit is contained in:
+10
-1
@@ -3,12 +3,21 @@
|
|||||||
# }
|
# }
|
||||||
|
|
||||||
extend type Query {
|
extend type Query {
|
||||||
mapitems: [MapItemInterface]
|
allmapitems: [MapItemInterface]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extend type Query {
|
||||||
|
mapitems(ids: [Int]): [MapItemInterface]
|
||||||
|
}
|
||||||
|
|
||||||
extend type Query {
|
extend type Query {
|
||||||
mapitem(id: Int!): MapItemInterface
|
mapitem(id: Int!): MapItemInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extend type Query {
|
||||||
|
allmapitemsof(familyId: Int!): [MapItemInterface]
|
||||||
|
}
|
||||||
|
|
||||||
extend type Query {
|
extend type Query {
|
||||||
texts: [TextInterface]
|
texts: [TextInterface]
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-1
@@ -168,7 +168,7 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|||||||
throw new Error('Could not resolve content type.');
|
throw new Error('Could not resolve content type.');
|
||||||
});
|
});
|
||||||
|
|
||||||
$registry->addFieldResolver('Query', 'mapitems',
|
$registry->addFieldResolver('Query', 'allmapitems',
|
||||||
$builder->compose(
|
$builder->compose(
|
||||||
$builder->callback(function($parent, $arg){
|
$builder->callback(function($parent, $arg){
|
||||||
$entity_storage = \Drupal::entityTypeManager()->getStorage('node');
|
$entity_storage = \Drupal::entityTypeManager()->getStorage('node');
|
||||||
@@ -184,11 +184,44 @@ class EnFrSchemaExtension extends SdlSchemaExtensionPluginBase {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$registry->addFieldResolver('Query', 'mapitems',
|
||||||
|
$builder->compose(
|
||||||
|
$builder->callback(function($parent, $arg){
|
||||||
|
$entity_storage = \Drupal::entityTypeManager()->getStorage('node');
|
||||||
|
$query = $entity_storage->getQuery()
|
||||||
|
->condition('type', ['texte', 'texte_prod', 'creation'], 'IN')
|
||||||
|
->accessCheck(TRUE);
|
||||||
|
$results = $query->execute();
|
||||||
|
return $results;
|
||||||
|
}),
|
||||||
|
$builder->produce('entity_load_multiple')
|
||||||
|
->map('type', $builder->fromValue('node'))
|
||||||
|
->map('ids', $builder->fromArgument('ids'))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$registry->addFieldResolver('Query', 'mapitem',
|
$registry->addFieldResolver('Query', 'mapitem',
|
||||||
$builder->produce('entity_load')
|
$builder->produce('entity_load')
|
||||||
->map('type', $builder->fromValue('node'))
|
->map('type', $builder->fromValue('node'))
|
||||||
->map('id', $builder->fromArgument('id'))
|
->map('id', $builder->fromArgument('id'))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$registry->addFieldResolver('Query', 'allmapitemsof',
|
||||||
|
$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)
|
||||||
|
->accessCheck(TRUE);
|
||||||
|
$results = $query->execute();
|
||||||
|
return $results;
|
||||||
|
}),
|
||||||
|
$builder->produce('entity_load_multiple')
|
||||||
|
->map('type', $builder->fromValue('node'))
|
||||||
|
->map('ids', $builder->fromParent())
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _____ _ ___ _
|
// _____ _ ___ _
|
||||||
|
|||||||
Reference in New Issue
Block a user