Experimenting using GraphQL in favor of REST.
This commit is contained in:
@@ -1,14 +1,97 @@
|
||||
import { get } from '../api';
|
||||
import { get, graphql } from '../api';
|
||||
|
||||
function initReleasesActions(store, _router) {
|
||||
function initReleasesActions(_store, _router) {
|
||||
async function fetchReleases({ _commit }) {
|
||||
/*
|
||||
const releases = await get('/releases', {
|
||||
filter: store.state.ui.filter,
|
||||
after: store.getters.after,
|
||||
before: store.getters.before,
|
||||
});
|
||||
*/
|
||||
|
||||
return releases;
|
||||
const { releases } = await graphql('MyQuery', `
|
||||
query MyQuery {
|
||||
releases(orderBy: DATE_DESC) {
|
||||
id
|
||||
title
|
||||
description
|
||||
date
|
||||
duration
|
||||
createdAt
|
||||
shootId
|
||||
url
|
||||
actors: actorsAssociateds {
|
||||
actor {
|
||||
id
|
||||
name
|
||||
slug
|
||||
origin: countryByBirthCountryAlpha2 {
|
||||
alpha2
|
||||
name
|
||||
}
|
||||
avatar: actorsMediasByTargetId(condition: { role: "avatar" }) {
|
||||
id
|
||||
thumbnail
|
||||
path
|
||||
mime
|
||||
}
|
||||
}
|
||||
}
|
||||
poster: releasesMediasByTargetId(condition: { role: "poster" }) {
|
||||
mime
|
||||
id
|
||||
index
|
||||
path
|
||||
thumbnail
|
||||
role
|
||||
}
|
||||
photos: releasesMediasByTargetId(condition: { role: "photos" }) {
|
||||
mime
|
||||
id
|
||||
index
|
||||
path
|
||||
thumbnail
|
||||
role
|
||||
}
|
||||
tags: releasesTagsByTargetId {
|
||||
tag {
|
||||
name
|
||||
priority
|
||||
slug
|
||||
id
|
||||
}
|
||||
}
|
||||
site {
|
||||
id
|
||||
name
|
||||
slug
|
||||
url
|
||||
network {
|
||||
id
|
||||
name
|
||||
slug
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
const curatedReleases = releases.map(release => ({
|
||||
...release,
|
||||
actors: release.actors.map(({ actor }) => ({
|
||||
...actor,
|
||||
avatar: actor.avatar[0],
|
||||
})),
|
||||
poster: release.poster[0],
|
||||
network: release.site.network,
|
||||
tags: release.tags.map(({ tag }) => tag),
|
||||
}));
|
||||
|
||||
console.log(curatedReleases);
|
||||
|
||||
return curatedReleases;
|
||||
}
|
||||
|
||||
async function fetchReleaseById({ _commit }, releaseId) {
|
||||
|
||||
Reference in New Issue
Block a user