MaterioSchema.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Drupal\materio_graphql\Plugin\GraphQL\Schema;
  3. use Drupal\graphql\Plugin\GraphQL\Schema\ComposableSchema;
  4. use Drupal\graphql\GraphQL\ResolverBuilder;
  5. use Drupal\graphql\GraphQL\ResolverRegistry;
  6. // use Drupal\graphql\Plugin\GraphQL\Schema\SdlSchemaPluginBase;
  7. use GraphQL\Error\Error;
  8. /**
  9. * @Schema(
  10. * id = "materio",
  11. * name = "Materio schema",
  12. * extensions = "materio",
  13. * )
  14. */
  15. class MaterioSchema extends ComposableSchema {
  16. // /**
  17. // * {@inheritdoc}
  18. // */
  19. // public function getResolverRegistry() {
  20. // $builder = new ResolverBuilder();
  21. // $registry = new ResolverRegistry();
  22. //
  23. // // Tell GraphQL how to resolve types of a common interface.
  24. // $registry->addTypeResolver('NodeInterface', function ($value) {
  25. // if ($value instanceof NodeInterface) {
  26. // switch ($value->bundle()) {
  27. // case 'article': return 'Article';
  28. // case 'materiau': return 'Materiau';
  29. // }
  30. // }
  31. // throw new Error('Could not resolve content type.');
  32. // });
  33. //
  34. // $registry->addFieldResolver('Query', 'route', $builder->compose(
  35. // $builder->produce('route_load')
  36. // ->map('path', $builder->fromArgument('path')),
  37. // $builder->produce('route_entity')
  38. // ->map('url', $builder->fromParent())
  39. // ));
  40. //
  41. // return $registry;
  42. // }
  43. }