Skip to content

Commit

Permalink
feat: Added support for studio resources (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel S authored Nov 13, 2021
1 parent aa6ed8d commit 45f5b15
Show file tree
Hide file tree
Showing 5 changed files with 489 additions and 2 deletions.
3 changes: 2 additions & 1 deletion plugins/gatsby-source-animethemes-db/src/create-resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ module.exports = ({ createResolvers }) => {
},
Studio: {
...pivotResolver({
anime: { type: "AnimeStudio", from: "studio", to: "anime" }
anime: { type: "AnimeStudio", from: "studio", to: "anime" },
resources: { type: "StudioResource", from: "studio", to: "resource" }
})
},
Theme: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ module.exports = ({ actions }) => {
slug: String!
name: String!
anime: [Anime]
resources: [Resource]
}
type AnimeSeries implements Node {
Expand Down Expand Up @@ -154,6 +155,11 @@ module.exports = ({ actions }) => {
studio: Studio! @link(by: "id")
}
type StudioResource implements Node {
studio: Studio! @link(by: "id")
resource: Resource! @link(by: "id")
}
type Announcement implements Node & Entity {
idRaw: Int
content: String!
Expand Down
12 changes: 12 additions & 0 deletions plugins/gatsby-source-animethemes-db/src/source-nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,18 @@ module.exports = async ({ actions, createNodeId, createContentDigest, reporter }
}, "AnimeStudio", helpers);
}

for (const studioResource of await selectAllFrom(
"studio_resource", true,
"studios", "studio_id", "studio_id",
"resources", "resource_id", "resource_id"
)) {
createNodeFromData({
id: `${studioResource.studio_id}-${studioResource.resource_id}`,
studio: createNodeId(`Studio-${studioResource.studio_id}`),
resource: createNodeId(`Resource-${studioResource.resource_id}`)
}, "StudioResource", helpers);
}

// await cache.set("last-fetched", now);
};

Expand Down
Loading

0 comments on commit 45f5b15

Please sign in to comment.