Open AndrewZamora opened 5 years ago
did you run npm install
? is there a faunadb
folder in your node_modules
?
@sw-yx Thank you for your reply. I didn't clone the repository. I just followed the tutorial. I have not npm installed faunadb
. For the tutorial am I suppose to clone and run the repo locally first?
ohh i see. yes, scroll up and start from "Setup & Run Locally"
@sw-yx Okay, thank you for your time!
I really appreciate your putting this tutorial together @DavidWells and @sw-yx, but, FWIW, I'm finding it confusing as well. Starting at the Tutorial header in the readme, it looks like it's walking you step by step through the setup process (and assuming you have not already cloned the repo). I think this mostly works, except it should also include a step to run npm install faunadb --save
before running npm run bootstrap
.
ok. added
Thanks, @sw-yx; I noticed, though, that the tutorial already includes a separate step where you install faunadb (substep 4 under "3. Create a function > Setting up functions for local development").
A couple of additional concerns:
Again under "3. Create a function > Setting up functions for local development", where it says "Your package.json
should look like...", that doesn't match the current package.json
in this repo: there's no proxy
field in the actual pkg, but there is in the readme version. I'm confused about how the repo proxies the locally served functions, and it's weird to have this disconnect.
In step 4 of the tutorial ("4. Connect the function to the frontend app"), it's not indicated where you should put that front-end code (though there is a reference to the /src
folder.)
When I clone the repo, install, and run, the app seems to be working, but I'm seeing warnings in my console when I do CRUD operations:
Request from ::ffff:127.0.0.1: POST /todos-create
Function `todo-create` invoked { title: 'Complete tutorial', completed: false }
success { ref: Ref(Class("todos"), "232907278267712002"),
ts: 1558376539460000,
data: { title: 'Complete tutorial', completed: false } }
Response with status 200 in 358 ms.
(node:46618) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'statusCode' of undefined
at callback ([...]/netlify-faunadb-example/node_modules/netlify-lambda/lib/serve.js:35:42)
at [...]/netlify-faunadb-example/node_modules/netlify-lambda/lib/serve.js:67:7
at [...]/netlify-faunadb-example/functions-build/todos-create.js:20:2972
at T ([...]/netlify-faunadb-example/functions-build/todos-create.js:20:3006)
at A ([...]/netlify-faunadb-example/functions-build/todos-create.js:20:2827)
at m ([...]/netlify-faunadb-example/functions-build/todos-create.js:20:728)
at process._tickCallback (internal/process/next_tick.js:61:11)
(node:46618) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
I'm running node v10.14.1. FWIW, the version I deployed directly to Netlify does not show these same warnings in the Functions logs, e.g.:
3:55:26 PM: todos-create invoked
3:55:26 PM: Function `todo-create` invoked { title: 'Check if there are errors in direct-to-Netlify version',
completed: false }
3:55:27 PM: success { ref: Ref(Class("todos"), "232924462000898562"),
ts: 1558392927140000,
data:
{ title: 'Check if there are errors in direct-to-Netlify version',
completed: false } }
Even though I got the cloned repo installed and working, and the deployed-directly-to-Netlify ("TLDR") version working, the Fauna dashboard is still showing the "Create your first database" message, and there doesn't appear to be any way for me to access the created db through Fauna's admin interface. The data is being stored to some db in Fauna, because my created to-dos are persisting across sessions, etc. Not sure if this is a bug with Fauna?
I am grateful for the effort put forth in writing this tutorial, but for me at least there's a lot that's preventing this from being as easy to follow as I think was intended.
re: 4 there is no bug, you just need to claim your database created using the secrets given in your environment variables (you can run netlify dev:exec echo $FAUNADB_SERVER_SECRET or something like that) creating via addon just sets you up as an anonymous user for now, we don’t have a database claims process yet with fauna but we definitely need to (cc @davidwells). in the meantime you can contact fauna support to do it.
re the rest, these are probably tutorial updates we need to make. i am going to reopen this issue to keep it in mind.
Thanks so much for replying so quickly, @sw-yx, and for explaining the claiming issue. (As you probably know, the readme doesn't mention this, and actually it specifically says that you should see the db created in your FaunaDB account.)
I look forward to the updated version of this tutorial -- thanks again for your help.
Posting this here in case it's helpful: I contacted Fauna support and here's what they said about claiming the bootstrapped DB created in this tutorial:
...the database that you create in netlify-faunadb is under netlify tenancy. Since you have key, you can access it through any driver or fauna shell.
Here are the steps
Install Fauna Shell - https://docs.fauna.com/fauna/current/quickstart
Update your key - Follow step 8 in https://docs.fauna.com/fauna/current/quickstart-github
Please note that You would still not be able to see these under Fauna Dashboard.
So, according to this support person, even after you claim the db, there's no way to have it appear in the dashboard:
Unfortunately at this point there is no way to [add it to the dashboard]. However, we have it on out product road map to integrate all these and have a seamless user experience.
Again, in case it's helpful to others, I was able to connect the todo app to a Fauna database that can be viewed from Fauna's dashboard.
To do so, I followed these steps:
Now when you create to-dos in the deployed app, you can view them from your database view in the Fauna dashboard.
we do need to make this claiming process easier. working on it with Fauna.
Hi @sw-yx -- for what it's worth, for my needs, manually creating the db in the Fauna console is totally fine; the programmatic bootstrapping process isn't necessary for me. Out of curiosity, what is the use-case for programmatic bootstrapping? Is the idea that an app could set up separate databases for each registered user or something? (That seems unlikely...) Thanks for any details you can provide, and thanks again for sharing this repo!
the idea is simply to do as much as possible with one command! :) so for example in netlify functions:create we let you scaffold out a function that interacts with a faunadb backend, AND set up a fauna instance for you all in one go. https://github.com/netlify/netlify-dev-plugin/tree/master/src/functions-templates/js/fauna-graphql
Thanks for explaining! (I was missing that bootstrapping includes actually creating the indexes and schema, etc. -- not just programmatically creating the db itself. I'm new to all this!)
Thank you for the tutorial.
I got stuck when I ran
npm run bootstrap
. This error showed up in the terminal:Is there something I overlooked in the tutorial?