It'd be awesome to be able to (at build time!) inject content from a SQL database, just like we do for other source types, e.g. filesystem, Contentful, etc.
The general idea is that the source plugin will need to be able to connect to a SQL database (MySQL, MSSQL, ... ?; happy to start small and grow it in the future!) and query that data to inject into the GraphQL content layer for further processing via Gatsby.
Consider mysql, mssql for various means to inject data
See other source plugins for more info on how to build this out, e.g. gatsby-source-contentful, gatsby-source-wordpress, etc.
me me me! Could you also direct on where to start? :)
@daubaris 馃憢 Absolutely! So I'd recommend checking out one of the source plugins I linked, and kinda re-tracing from there!
So high level, this is what this will look like:
sourceNodes)If you're interested, we'd love to help out with a pairing session, as well. Sign up for those here
And let me know if I can help with this further :)
If I were to suggest sqlite support as well, would that be lumped into this plugin or it's own thing?
@garetmckinley good question! I'm not sure how to best resolve that complexity to be honest with you.
_Ideally_ there'd be one shared sql plugin, but the more I think about it, I'm not sure how tenable that is because the _engine_ will have to change between MySQL, mssql, SQLLite, etc.
So we may be able to introduce some shared helpers, but I think this plugin may take additional plugins, and those plugins should implement some API perhaps?
(very similar to gatsby-transformer-remark if you're familiar!)
Yeah, I think that makes the most sense! I'll keep an eye on the progress of this issue, because I have a use-case for gatsby with sqlite. I'd be more than happy to work on a sqlite plugin for this source when the time comes.
@garetmckinley that would be so great! Stay tuned 馃憖
Once this progresses i d like to look for some postgres integration as well.
Is this claimed?
Is this open? If so I would like to work on it if someone's not doing it already.
@mrfunnyshoes do it if not even for the learning experience.
@mrfunnyshoes yep! Feel free to tackle this, we'd love to see this!
Thanks! Do you guys think using knex be overkill for this task?
@mrfunnyshoes. Whoa, I鈥檝e never heard of that! That seems like a nice, flexible option!
All for it!
I just implemented something similar, but for mysql only. It is just a thin wrapper around the library mysql. See https://github.com/malcolm-kee/gatsby-source-mysql
@malcolm-kee great! I think there's still some value in what @mrfunnyshoes proposed, so perhaps we can work on integrating gatsby-source-sql into _this_ repo whereas yours can live under your own name!
Looks great, though - happy to see more plugins relating to this! Nice work!
@dschau agree! That is much useful than only support mysql. Just share as another reference 馃榿
Hey guys! I've got a working version here. Let me know what you think. I'm actually new to contributing to a FOSS project.
PS: I think It would be nice to nest the resulting data inside the fieldName for the query, much in the way gatsby-source-graphql does.
@mrfunnyshoes my suggestions:
Other than that, great works!
Thanks @malcolm-kee, will look into your suggestions!
@mrfunnyshoes this is incredible.
Would you consider it production ready? If so, could you publish this to NPM? This will submit it to the plugin library as well!
cc @DSchau
https://github.com/gatsbyjs/gatsby/pull/8875
There鈥檚 is already this PR
@malcolm-kee we'd love to have this plugin in the official Gatsby repository. I haven't taken a super close look at the code, but the functionality you're able to build in (in a database agnostic way) looks _perfect_.
Perhaps we schedule some time next week, and I can walk you through how we'd get this PR'd up to the official Gatsby monorepo? Feel free to use my Calendly and we can get this up and running.
Again--thank you! This looks great!
@DSchau are you intends to message @mrfunnyshoes for gatsby-source-sql?
Hey guys @DSchau, @malcolm-kee! Yes, I think we could start working on the PR. Should I publish this to npm already, or will that be part of adding it to the monorepo?
@mrfunnyshoes Hi! So is your plugin ready to go for a PR against Gatsby's repo? If so we should close this PR https://github.com/gatsbyjs/gatsby/pull/8875 and you can open up yours. Please let us know if you need help with the PR.
I don't think you need to publish to npm as the monorepo will handle this once your PR is merged 馃憤
Thanks @LekoArts! I _think_ the plugin is ready for PR, I'm not completely sure how to proceed with it though. I'll start by following these instructions and come here with any doubts.
If you have problems you can also join our Discord (https://discord.gg/jUFVxtB) and ask there 馃憤 (Or open the PR and we'll talk in the PR)
Thanks @LekoArts, I submitted a PR
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
Thanks for being a part of the Gatsby community! 馃挭馃挏
Hey again!
It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
Thanks again for being part of the Gatsby community!
Reopening as there is a related PR open for this.
Closing this since https://github.com/gatsbyjs/gatsby/pull/11100#issuecomment-486755549
Keep an eye out for @mrfunnyshoes's fantastic plugin that will enable this!
FYI:
if someone search for this - the plugin is here available: