rsnext/examples/with-graphql-faunadb/README.md

55 lines
1.9 KiB
Markdown
Raw Normal View History

# FaunaDB Graphql Starter Example -- The FaunaDB Guestbook
This simple Guestbook SPA example shows you how to use [FaunaDB's GraphQL endpoint](https://docs.fauna.com/fauna/current/api/graphql/) in your Next.js project. [[Live demo](https://with-graphql-faunadb.now.sh/)].
## Why FaunaDB
By importing a `.gql` or `.graphql` schema into FaunaDB ([see our sample schema file](./schema.gql)), FaunaDB will generate required Indexes and GraphQL resolvers for you -- hands free 👐 ([some limitations exist](https://docs.fauna.com/fauna/current/api/graphql/#limitations)).
## How to use
2019-11-13 22:26:08 +01:00
You can start with this template [using `create-next-app`](#using-create-next-app) or by [downloading the repository manually](#download-manually).
To use a live FaunaDB database, create one and import this example's `schema.gql` file using the FaunaDB console. Create a client secret, then paste it into `next.config.js`.
2019-11-13 22:26:08 +01:00
### Using `create-next-app`
2019-11-13 22:26:08 +01:00
Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) to bootstrap the example:
```
2019-11-13 22:26:08 +01:00
npx create-next-app --example with-graphql-faunadb with-graphql-faunadb
# or
yarn create next-app --example with-graphql-faunadb with-graphql-faunadb
```
### Download manually
2019-11-13 22:26:08 +01:00
Download the example:
```bash
curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-graphql-faunadb
cd with-graphql-faunadb
```
### Run locally
2019-11-13 22:26:08 +01:00
Install packages, then run the development server:
```bash
npm install
2019-11-13 22:26:08 +01:00
npm run dev
# or
yarn
yarn dev
```
Make sure to leave us a guestbook message in our [live demo](https://with-graphql-faunadb.now.sh/)! 😉
### Deploy
Deploy it to the cloud with [now](https://zeit.co/now)! [Install now](https://zeit.co/download) on your development machine before proceeding.
```bash
now
```