Enable multiple instances
ynnoj opened this issue · comments
Currently when building the nodes, the types used are generic (TransistorShow
, TransistorEpisode
). This permits using multiple instances of the plugin to query different Transistor shows.
One way to allow this would be to require a new configuration key that is passed to the createNode
help to generate unique types for nodes.
I've been thinking about how to solve this without polluting the schema. Ideally we want a single allTransistorShow
query, rather than multiple (per feed) but scoped episode queries per feed.
// gatsby-config.js
{
resolve: `gatsby-source-transistorfm`,
options: {
feeds: [{
key: `DevTyne`,
url: `https://feeds.transistor.fm/devonthetyne`
}]
}
}
Then we use the key
to build episode nodes specific to that feed (i.e. allDevTyneTransistorEpisode
).
@notrab Thoughts?
@ynnoj perhaps we can follow the gatsby-source-filesystem
/gatsby-source-graphql
plugins that have name
/typeName
fields, which would make multiple allTransistorShow
by default, so perhaps we look how those work under the hood to prevent it?
@notrab Why would you want multiple allTransistorShow
queries that only ever return one result? I don't think that comparison is fair those plugins can/will have multiple types.
gatsby-source-graphql
reads a remote schema, and nodes (strictly speaking) aren't even created in the same fashion as an actual source plugin such as this one.
Using multiple instances out of the box works for allTransistorShow
:
{
resolve: 'gatsby-source-transistorfm',
options: {
url: 'https://feeds.transistor.fm/devonthetyne',
},
},
{
resolve: 'gatsby-source-transistorfm',
options: {
url: 'https://feeds.transistor.fm/first-means-everything-radio',
},
},
I think rather than complicating this, perhaps we just need to add the show/episode reference to the nodes?
@notrab Perhaps this can be closed?