Netlify functions:create (Fauna w/ GraphQL option) does not show up in the FaunaDB Dashboard

Hello. Thank you for any help you can provide here is a detail of the goal I am trying to achieve, the steps that I have taken to try and achieve this goal, and the error messages that have come along the way.

** I have gone through all of this with the FaunaDB support team, and we are confident it is a porblem with Netlify and not on the Fauna Addon side **

GOAL: To be able to see the FaunaDB (GraphQL) database that was created with netlify functions:create in the Fauna dashboard

ACTION 1: netlify addons:auth fauna

RESULT:

  • The Fauna dashboard did populate with the schema from my Netlify Functions schema
  • BUT then on netlify dev I get the following error message:
    • Response with status 500 in 264 ms. ◈ Error during invocation: [ { message: ‘Ref refers to undefined database ‘backend’’, extensions: { code: ‘invalid ref’ } } ]

ACTION 2: because ‘backend’ was undefined I deleted that DB in the newly populated Fauna Dashboard

RESULT:

  • When I run netlify dev now I get the following error message:
    • ◈ Error during invocation: [ { message: ‘Invalid database secret.’ } ] Request from ::1: POST /.netlify/functions/backend Response with status 500 in 234 ms.

ACTION 3: netlify addons:list

RESULT:

  • | fauna | FaunaDB Cloud | 5d741a8ed6e05ec5f3e7ca35
  • | identity | Netlify Identity | 5d76a44c547979017630f3eb

ACTION 4: netlify addons:delete fauna

ACTION 5: netlify addons:create fauna && netlify addons:auth fauna AND I update my schema.graphql file inside the Fauna Dashboard

RESULT:

  • Now again my Fauna database is populated in the Fauna dashboard.
  • BUT now the problem is all of my queries are still trying to hit the /.netlify/functions/backend directory that was created in when I followed the old way of netlify:functions create
  • AND when I run netlify dev the project is still injecting my old credentials into the site:
    • ◈ Netlify Dev ◈
    • ◈ Injected addon env var: FAUNADB_ADMIN_SECRET
    • ◈ Injected addon env var: FAUNADB_SERVER_SECRET
    • ◈ Injected addon env var: FAUNADB_CLIENT_SECRET
    • ◈ Starting Netlify Dev with gatsby
    • Waiting for localhost:8000.
    • ◈ Lambda server is listening on 34567

ACTION 6: I deleted the /.netlify/functions/backend directory from my local files. And I even deleted my whole Netlify site. Created a new netlify site from the same git and local directory.

RESULT:

MAIN PROBLEM NOW:

How can I get my Fauna DB with the schema populated in the Fauna Dashboard to work with my Netlify site?

netlify functions:create and netlify addons:auth fauna do not work together

1 Like

Hi Ryan – I’ve run into a similar issue. Did you find a way to fix this?

Same here, I’m encountering a similar issue as well.

Hey there! I’m Lewis, a PM with Fauna. I’ve been chatting with the Netlify team about this.

Please try to create the function that you need in JS. netlify functions:create uses prebundled templates that probably doesn’t match the schema you are using

Try this:

  1. netlify addons:create fauna
  2. netlify addons:auth fauna
  3. create your FaunaDB schema in the Console
  4. create a functions folder and add to netlify.toml in the build.functions block:
[build]
   functions = "functions"
  1. Add the code needed to functions/whatever-function-name.js that talks to FaunaDB

Please let us know if this is helpful, and happy to continue helping on the Fauna side!

1 Like