import { graphql } from '../api'; import { releasesFragment, releaseFragment } from '../fragments'; import { curateRelease } from '../curate'; function initReleasesActions(_store, _router) { async function fetchReleases({ _commit }, { limit = 100 }) { /* const releases = await get('/releases', { filter: store.state.ui.filter, after: store.getters.after, before: store.getters.before, }); */ const { releases } = await graphql(` query Releases($limit:Int!) { ${releasesFragment} } `, { limit, }); return releases.map(release => curateRelease(release)); } async function fetchReleaseById({ _commit }, releaseId) { // const release = await get(`/releases/${releaseId}`); const { release } = await graphql(` query Release($releaseId:Int!) { ${releaseFragment} } `, { releaseId: Number(releaseId), }); return curateRelease(release); } return { fetchReleases, fetchReleaseById, }; } export default initReleasesActions;