Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: views extension #37

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
3 changes: 3 additions & 0 deletions graphql/thunder_views.extension.graphqls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extend type Query {
views(view_id: String!, display_id: String, offset: Int, page_size: Int, page: Int): [Page]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use camel case in the graphql schema

}
35 changes: 35 additions & 0 deletions src/Plugin/GraphQL/SchemaExtension/ThunderViewsSchemaExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Drupal\thunder_gqls\Plugin\GraphQL\SchemaExtension;

use Drupal\graphql\GraphQL\ResolverRegistryInterface;

/**
* Adds the views extension.
*
* @SchemaExtension(
* id = "thunder_views",
* name = "Views extension",
* description = "Adds the views extension.",
* schema = "thunder"
* )
*/
class ThunderViewsSchemaExtension extends ThunderSchemaExtensionPluginBase {

/**
* {@inheritdoc}
*/
public function registerResolvers(ResolverRegistryInterface $registry) {
parent::registerResolvers($registry);

$this->addFieldResolverIfNotExists('Query', 'views',
$this->builder->produce('views')
->map('view_id', $this->builder->fromArgument('view_id'))
->map('display_id', $this->builder->fromArgument('display_id'))
->map('offset', $this->builder->fromArgument('offset'))
->map('page_size', $this->builder->fromArgument('page_size'))
->map('page', $this->builder->fromArgument('page'))
);
}

}