Skip to content

Commit

Permalink
Added slug and uri response for linked entries and categories
Browse files Browse the repository at this point in the history
  • Loading branch information
freimutt committed Jan 28, 2020
1 parent f6238b8 commit f7ebdb7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.2.1 - 2020-01-28
### Added
- Added slug and uri response for linked entries and categories

## 1.2.0 - 2019-11-01
### Added
- Added caftql plugin support
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dutchheight/craft-navie",
"description": "Navigation plugin for Craft CMS 3",
"type": "craft-plugin",
"version": "1.2.0",
"version": "1.2.1",
"keywords": [
"craft",
"cms",
Expand Down
12 changes: 6 additions & 6 deletions src/graphql/interfaces/ListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace dutchheight\navie\graphql\interfaces;

use craft\gql\GqlEntityRegistry;
use craft\gql\interfaces\Structure;
use craft\gql\TypeLoader;
use dutchheight\navie\elements\ListItem as ListItemElement;

use dutchheight\navie\graphql\arguments\ListItem as ListItemArguments;
use dutchheight\navie\graphql\interfaces\ListItem as ListItemInterface;
use dutchheight\navie\elements\ListItem as ListItemElement;
use dutchheight\navie\graphql\types\generators\ListItemType;

use craft\gql\interfaces\Structure;
use craft\gql\TypeLoader;
use craft\gql\GqlEntityRegistry;
use GraphQL\Type\Definition\InterfaceType;
use GraphQL\Type\Definition\Type;

Expand Down Expand Up @@ -111,4 +111,4 @@ public static function getFieldDefinitions(): array {
]
]);
}
}
}
16 changes: 10 additions & 6 deletions src/graphql/types/ListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace dutchheight\navie\graphql\types;

use dutchheight\navie\graphql\interfaces\ListItem as ListItemInterface;
use dutchheight\navie\elements\ListItem as ListItemElement;

use craft\gql\interfaces\Element as ElementInterface;
use craft\gql\base\ObjectType;
use craft\gql\interfaces\Element as ElementInterface;

use dutchheight\navie\elements\ListItem as ListItemElement;
use dutchheight\navie\graphql\interfaces\ListItem as ListItemInterface;
use GraphQL\Type\Definition\ResolveInfo;

/**
Expand Down Expand Up @@ -39,6 +39,7 @@ protected function resolve($source, $arguments, $context, ResolveInfo $resolveIn
$fieldName = $resolveInfo->fieldName;

$list = $source->getList();
$element = $source->getElement();

switch ($fieldName) {
case 'listId':
Expand All @@ -53,9 +54,12 @@ protected function resolve($source, $arguments, $context, ResolveInfo $resolveIn
return $list->propagate;
case 'url':
return $source->getUrl();
case 'slug':
return $element->slug ?? null;
case 'uri':
return $element->uri ?? null;
}

return $source->$fieldName;
}

}
}
14 changes: 7 additions & 7 deletions src/graphql/types/generators/ListItemType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace dutchheight\navie\graphql\types\generators;

use dutchheight\navie\Navie;
use dutchheight\navie\graphql\interfaces\ListItem as ListItemInterface;
use dutchheight\navie\elements\ListItem as ListItemElement;
use dutchheight\navie\models\ListModel;
use dutchheight\navie\graphql\types\ListItem;

use craft\base\Field;
use craft\gql\base\GeneratorInterface;
use craft\gql\GqlEntityRegistry;
use dutchheight\navie\elements\ListItem as ListItemElement;
use dutchheight\navie\graphql\interfaces\ListItem as ListItemInterface;

use dutchheight\navie\graphql\types\ListItem;
use dutchheight\navie\models\ListModel;
use dutchheight\navie\Navie;

class ListItemType implements GeneratorInterface
{
Expand Down Expand Up @@ -46,4 +46,4 @@ public static function generateTypes($context = null): array

return $gqlTypes;
}
}
}

0 comments on commit f7ebdb7

Please sign in to comment.