Set up Gatsby + faunadb (graphql)

Hi, I am trying to set up my project base using gatsby and fauna.
I wonder, that there are like no useful information on how to do this, for this maybe a very relevant setup right now.

What I did so far:

  • Init a gatsby project
  • netlify init
  • netlify addons:create fauna
  • netlify addons:auth fauna
  • netlify functions:create fauna-graphql`
  • cd functions/fauna-graphql && npm i


  command = "npm run build"
  functions = "functions"
  publish = "public"

Used this project to get a hang on how this could work: (it is not building, the packages are outdated)

Used this as a basis: (without gatsby-source-graphql, for I don’t want to use it)

This is the endpoint if I netlify deploy --prod: (working fine)

I did add GATSBY_FAUNADB_SERVER_SECRET, and FAUNADB_SERVER_SECRET to env for testing purpose.
The cli did show Error during invocation: [ { message: ‘Invalid database secret.’ } ], but this did not solve it.

If I request
const query = gql { findTestByID(id: "251385935861645826") { name } }
from the netlify dev server, the response is the gatsby index.html from of the public/ folder.
The js console logs: Error: Network error: Unexpected token < in JSON at position 0

If someone set that up, it would be very kind to upload a base template to github for the community.
This really is, what people need to get started.

Please add faunadb to the community tag selection.

We don’t have a lot more knowledge about fauna on our team than is already shown in the docs, sorry to say - not sure what we’d put in a FAQ. It tends to just work for most folks.

If you’re using it in a function please be aware that functions will ONLY use environment variables that are set in our UI (here: - if you set them in netlify.toml functions CANNOT see them.

I think that may be all you need to get working but if not, let us know and we’ll try to get back to you faster after you try that out for us than we did this time.

Following the course at (github)
I am having the same issue

@barhoringamir - we’d need to know more to help! did you consider our advice above? Which site is this? what are you trying to accomplish and what behaviour are you seeing? :thinking: