FaunaDB Connection Assistance

Hello, hoping someone can fill in the missing gaps in my understanding of how to set up the REST interface in the Data area to connect to FaunaDB. FaunaDB is graphql API and I have spent many hours trying to get something to work at all. Wondering if it isn’t possible through Appgyver or what have whatnot.

I’m presuming it is my ignorance of most of the API REST vs GraphQL and lack of knowledge around formatting and content I need to put into Appgyver areas for the various REST (get, post, etc) to work with FaunaDB. (relative path, response key path, headers, parameters, etc). I have a secret/key I’m to use but unsure of where to use and how (encode in Base area or will that expose it publically, etc?). I have my FaunaDB setup, although I haven’t yet put any actual rows of data/documents in it yet but easily can if needed.

Hi there!

Let me try and explain some of terminology:

REST API = an API that implements REST (typically over the protocol HTTP)
JSON REST API = REST API that communicates in JSON payloads (other options are for example XML, HTML)
GraphQl = a query language for databases, in this case FaunaDB. The queries are not JSON, but the results are often returned as JSON documents.

In the case of AppGyver we support JSON over REST API for integrations. So to work with FaunaDB you’ll need to be able to send GraphQL queries as HTTP requests towards their endpoint.

FaunaDB documentation has some information on this in their documentation: https://docs.fauna.com/fauna/current/api/graphql/endpoints
in particular they reference this url https://graphql.org/learn/serving-over-http/

However depending on the case, this might not a very ergonomic/convenient way of doing things.
Another option is to build a REST API that interacts as a middleware layer between FaunaDB and applications such as AppGyver. An example of this approach can be found here: https://css-tricks.com/build-a-100-serverless-rest-api-with-firebase-functions-faunadb/

Hope this helps!

1 Like