Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect Gatsby with Postgres

I would like to pull data from Postgres to Gatsby using graphql. I have written node.js server, but i cannot find way to use it in gatsby. (https://github.com/gstuczynski/graphql-postgres-test) Have you any ideas?

like image 202
tyskocz Avatar asked Oct 17 '25 17:10

tyskocz


1 Answers

What you need to do is implement a source plugin as seen here https://www.gatsbyjs.org/docs/create-source-plugin/.

There are many examples within the gatsby repository that implement the source api. See those for inspiration! Basically you need to translate the contents of your Postgres db into a format gatsby understands. Gatsby calls this format “nodes”.

You could implement a plugin which interfaces with your db directly or with whatever api your node server exposes (graphql, REST etc.).

like image 149
dkweave Avatar answered Oct 20 '25 08:10

dkweave