Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/0.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
CMeeg committed Apr 13, 2020
2 parents c02fb3f + cc0b8ce commit c1a8a77
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## 0.4.1 (2020-04-13)

### Bug Fixes

* Changes to fix issues with Asset-related errors raised on [#11](https://github.com/CMeeg/gridsome-source-kentico-kontent/issues/11) and [#12](https://github.com/CMeeg/gridsome-source-kentico-kontent/issues/12)
* Do not add url field resolver if Assets collection is empty ([9900350](https://github.com/CMeeg/gridsome-source-kentico-kontent/commit/9900350))
* Resolver for Asset.url must have a "type" property ([4e322c9](https://github.com/CMeeg/gridsome-source-kentico-kontent/commit/4e322c9))

## 0.4.0 (2019-11-17)

### ⚠ BREAKING CHANGES
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meeg/gridsome-source-kentico-kontent",
"version": "0.4.0",
"version": "0.4.1",
"description": "Kentico Kontent data source plugin for Gridsome.",
"author": "Chris Meagher",
"license": "MIT",
Expand Down
25 changes: 21 additions & 4 deletions src/KenticoKontentSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,20 +275,37 @@ class KenticoKontentSource {
}

addSchemaResolvers(store) {
this.addAssetSchemaResolvers(store);
}

addAssetSchemaResolvers(store) {
const typeName = this.contentItemFactory.getAssetTypeName();

const assetCollection = this.getCollection(store, typeName);

if (assetCollection.collection.data.length === 0) {
// There are no assets so no need for resolvers

return;
}

// Get and add asset resolvers

const { addSchemaResolvers } = store;
const assetResolvers = this.getAssetSchemaResolvers(typeName);

addSchemaResolvers(this.getAssetSchemaResolvers());
addSchemaResolvers(assetResolvers);
}

getAssetSchemaResolvers() {
getAssetSchemaResolvers(typeName) {
// TODO: This doesn't feel like the right place to do this

const typeName = this.contentItemFactory.getAssetTypeName();

const resolvers = {};

resolvers[typeName] = {
url: {
type: 'String',
defaultValue: null,
args: {
width: {
type: 'Int',
Expand Down

0 comments on commit c1a8a77

Please sign in to comment.