Wanted: Simplest possible "quick start"

I am looking for the simplest possible “quick start.” While I have enjoyed working my way through the React “quick start,” I am not a React developer and my use cases will not be built using React.

Does anyone have a simple, entirely generic, example of how to use 8Base?

Here’s what I’d like to see:

  • Execute a serverless function, via curl, that returns a value, via GraphQL, from the database.
  • Execute a serverless function, via a http request in a web browser, that returns a value, via GraphQL, from the database.

The examples should not even use Express.

Can anyone help?

Thank you.

Hey Talgolan!

I accept your challenge ♘

Give me the weekend and I’ll give toy something that fits the vision.

Sebastian

1 Like

Sebastian: Thank you.

If you use GitHub, please let me know and I will be happy to collaborate with you.

1 Like

Hey Tal!

I just started on this. Here is the repo. It’s not done.

What do you think should be possible in the simplest app? As in, what functionality should be possible?

Thanks!

Thanks for asking. :slight_smile:

Minimum requirements for the “simplest app.”

  • Define a schema for a basic table (Contact): UniqueID, FName, LName, Email

  • Populate the (Contact) table with some random data (ex. use https://swapi.co/ and grab 10 random characters).

  • Expose an endpoint that can be called from the command-line, via a curl request, that will return a JSON record. Something like:

    Return all (Contact) records

    curl -i -H “Accept: application/json” -H “Content-Type: application/json” -X GET “http://hostname/contacts/all

    Return the (Contact) record matching id=

    curl -i -H “Accept: application/json” -H “Content-Type: application/json” -X GET “http://hostname/contacts/id=

    Return the (Contact) record matching graphql query

    curl -i -H “Accept: application/json” -H “Content-Type: application/json” -X GET “http://hostname/contacts/query=

  • Expose an endpoint that can be called via http(s), via a curl request, that will return a JSON record in the browser. Something like:

    Return all (Contact) records

    http://hostname/contacts/all

    Return the (Contact) record matching id=

    http://hostname/contacts/id=

    Return the (Contact) record matching graphql query

    http://hostname/contacts/query=

  • Both of the above, but with basic authentication.

Ahhh! We don’t even need custom functions in this case. Everything will be auto generated by 8base for the Contacts table and available via the GraphQL endpoint.

Revisiting the application now.

Wonderful. Like I said… The “simplest application” for the sake of a “fastest quick start.”

Alright man, I think I have you covered! Check it out: https://github.com/8base/simplest-starter-app

Usage

Go into the contacts.sh file and replace the following variables with valid values.

  1. API_TOKEN=<YOUR_API_TOKEN>
  2. WORKSPACE_ENDPONT=<YOUR_WORKSPACE_ENDPOINT>

CURL

There are three commands.

all

bash contacts.sh all

id

bash contacts.sh id "123_id_of_some_record"

query

bash contacts.sh query "{ contactsList { count } }"

BROWSER

There are three HTTP options.

all

https://api.8base.com/<WORKSPACE_ID>/webhook/contacts?type=all

id

https://api.8base.com/<WORKSPACE_ID>/webhook/contacts?type=id&value=<CONTACT_ID>

query

Note: query only queries by the email field, as it is difficult passing an query object through the browser’s URL input
https://api.8base.com/<WORKSPACE_ID>/webhook/contacts?type=query&value=<SOME_QUERY>

Auth

I added auth to the Curl, but not the webhook. If you’re using an API client, like Postman, it would be easy to add an Authorization Header.

Thank you. I will give this a try as soon as possible (later tonight or tomorrow).

Sebastian: You nailed it. Thank you.

I have a couple of suggestions that I would like to submit as a pull request.

Are you comfortable adding me to the repo?

GitHub Username: talgolan

Let me know.

1 Like

Wooo hooo!

Invite sent. It should allow you to make pull requests.

I think “simplest” is subjective, in terms of what and how simple. For example, the simplest to me is:

8base:

Create a table with a few fields
Create a new role to access tables
Create a new API token and associate with role

Client:

Create a new npm app with npm init
Install apollo-boost, graphql-tag, …
Create a simple React/Vue/LitElement app
Use Apollo client.query() to get and present data

For me, the key is using JavaScript, and focused on the front-end. If there were a CDN version of the Apollo client, you wouldn’t even need a specific framework, just an HTML page with JavaScript.

I found https://www.jsdelivr.com/package/npm/apollo-boost but I’m not familiar with loading libraries any more ever since using Webpack… but we’re heading in that direction again with JS modules.

1 Like

Simplest JavaScript app? Could be a thing!